diff --git a/public/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java b/public/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java index f5590b708..38ef2879b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java +++ b/public/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisEngine.java @@ -1034,123 +1034,16 @@ public class GenomeAnalysisEngine { return readsDataSource == null ? null : readsDataSource.getCumulativeReadMetrics(); } - public SampleDataSource getSampleMetadata() { + // ------------------------------------------------------------------------------------- + // + // code for working with Samples database + // + // ------------------------------------------------------------------------------------- + + public SampleDataSource getSampleDB() { return this.sampleDataSource; } - /** - * Get a sample by its ID - * If an alias is passed in, return the main sample object - * @param id sample id - * @return sample Object with this ID - */ - public Sample getSampleById(String id) { - return sampleDataSource.getSampleById(id); - } - - /** - * Get the sample for a given read group - * Must first look up ID for read group - * @param readGroup of sample - * @return sample object with ID from the read group - */ - public Sample getSampleByReadGroup(SAMReadGroupRecord readGroup) { - return sampleDataSource.getSampleByReadGroup(readGroup); - } - - /** - * Get a sample for a given read - * Must first look up read group, and then sample ID for that read group - * @param read of sample - * @return sample object of this read - */ - public Sample getSampleByRead(SAMRecord read) { - return getSampleByReadGroup(read.getReadGroup()); - } - - /** - * Get number of sample objects - * @return size of samples map - */ - public int sampleCount() { - return sampleDataSource.sampleCount(); - } - - /** - * Return all samples with a given family ID - * Note that this isn't terribly efficient (linear) - it may be worth adding a new family ID data structure for this - * @param familyId family ID - * @return Samples with the given family ID - */ - public Set getFamily(String familyId) { - return sampleDataSource.getFamily(familyId); - } - - /** - * Returns all children of a given sample - * See note on the efficiency of getFamily() - since this depends on getFamily() it's also not efficient - * @param sample parent sample - * @return children of the given sample - */ - public Set getChildren(Sample sample) { - return sampleDataSource.getChildren(sample); - } - - /** - * Gets all the samples - * @return - */ - public Collection getSamples() { - return sampleDataSource.getSamples(); - } - - /** - * Takes a list of sample names and returns their corresponding sample objects - * - * @param sampleNameList List of sample names - * @return Corresponding set of samples - */ - public Set getSamples(Collection sampleNameList) { - return sampleDataSource.getSamples(sampleNameList); - } - - - /** - * Returns a set of samples that have any value (which could be null) for a given property - * @param key Property key - * @return Set of samples with the property - */ - public Set getSamplesWithProperty(String key) { - return sampleDataSource.getSamplesWithProperty(key); - } - - /** - * Returns a set of samples that have a property with a certain value - * Value must be a string for now - could add a similar method for matching any objects in the future - * - * @param key Property key - * @param value String property value - * @return Set of samples that match key and value - */ - public Set getSamplesWithProperty(String key, String value) { - return sampleDataSource.getSamplesWithProperty(key, value); - - } - - /** - * Returns a set of sample objects for the sample names in a variant context - * - * @param context Any variant context - * @return a set of the sample objects - */ - public Set getSamplesByVariantContext(VariantContext context) { - Set samples = new HashSet(); - for (String sampleName : context.getSampleNames()) { - samples.add(sampleDataSource.getOrCreateSample(sampleName)); - } - return samples; - } - /** * Returns all samples that were referenced in the SAM file */ @@ -1158,18 +1051,6 @@ public class GenomeAnalysisEngine { return sampleDataSource.getSAMFileSamples(); } - /** - * Return a subcontext restricted to samples with a given property key/value - * Gets the sample names from key/value and relies on VariantContext.subContextFromGenotypes for the filtering - * @param context VariantContext to filter - * @param key property key - * @param value property value (must be string) - * @return subcontext - */ - public VariantContext subContextFromSampleProperty(VariantContext context, String key, String value) { - return sampleDataSource.subContextFromSampleProperty(context, key, value); - } - public Map getApproximateCommandLineArguments(Object... argumentProviders) { return CommandLineUtils.getApproximateCommandLineArguments(parsingEngine,argumentProviders); } diff --git a/public/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContextUtils.java b/public/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContextUtils.java index 707f4e97c..f77fbe4e9 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContextUtils.java +++ b/public/java/src/org/broadinstitute/sting/gatk/contexts/AlignmentContextUtils.java @@ -26,7 +26,6 @@ package org.broadinstitute.sting.gatk.contexts; import net.sf.samtools.SAMReadGroupRecord; -import org.broadinstitute.sting.gatk.samples.Sample; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.exceptions.UserException; @@ -76,14 +75,6 @@ public class AlignmentContextUtils { return splitContextBySampleName(context, null); } - public static Map splitContextBySample(AlignmentContext context) { - Map m = new HashMap(); - for ( Map.Entry entry : splitContextBySampleName(context, null).entrySet() ) { - m.put(new Sample(entry.getKey()), entry.getValue()); - } - return m; - } - /** * Splits the given AlignmentContext into a StratifiedAlignmentContext per sample, but referencd by sample name instead * of sample object. diff --git a/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java b/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java index 09ab4bd44..b7846399f 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java +++ b/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java @@ -56,7 +56,7 @@ public class LinearMicroScheduler extends MicroScheduler { traversalEngine.startTimersIfNecessary(); if(shard.getShardType() == Shard.ShardType.LOCUS) { LocusWalker lWalker = (LocusWalker)walker; - WindowMaker windowMaker = new WindowMaker(shard, engine.getGenomeLocParser(), getReadIterator(shard), shard.getGenomeLocs(), engine.getSampleMetadata()); + WindowMaker windowMaker = new WindowMaker(shard, engine.getGenomeLocParser(), getReadIterator(shard), shard.getGenomeLocs(), engine.getSampleDB()); for(WindowMaker.WindowMakerIterator iterator: windowMaker) { ShardDataProvider dataProvider = new LocusShardDataProvider(shard,iterator.getSourceInfo(),engine.getGenomeLocParser(),iterator.getLocus(),iterator,reference,rods); Object result = traversalEngine.traverse(walker, dataProvider, accumulator.getReduceInit()); diff --git a/public/java/src/org/broadinstitute/sting/gatk/executive/ShardTraverser.java b/public/java/src/org/broadinstitute/sting/gatk/executive/ShardTraverser.java index 2b6488ada..428813b71 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/executive/ShardTraverser.java +++ b/public/java/src/org/broadinstitute/sting/gatk/executive/ShardTraverser.java @@ -62,7 +62,7 @@ public class ShardTraverser implements Callable { Object accumulator = walker.reduceInit(); LocusWalker lWalker = (LocusWalker)walker; - WindowMaker windowMaker = new WindowMaker(shard,microScheduler.getEngine().getGenomeLocParser(),microScheduler.getReadIterator(shard),shard.getGenomeLocs(), microScheduler.engine.getSampleMetadata()); // todo: microScheduler.engine is protected - is it okay to user it here? + WindowMaker windowMaker = new WindowMaker(shard,microScheduler.getEngine().getGenomeLocParser(),microScheduler.getReadIterator(shard),shard.getGenomeLocs(), microScheduler.engine.getSampleDB()); // todo: microScheduler.engine is protected - is it okay to user it here? ShardDataProvider dataProvider = null; for(WindowMaker.WindowMakerIterator iterator: windowMaker) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java b/public/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java index 2f25bf7b1..61b861fd6 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java +++ b/public/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java @@ -542,7 +542,7 @@ public class LocusIteratorByState extends LocusIterator { Map readSelectors = new HashMap(); for(Sample sample: samples) { readStatesBySample.put(sample,new PerSampleReadStateManager()); - readSelectors.put(sample.getId(),downsamplingMethod.type == DownsampleType.BY_SAMPLE ? new NRandomReadSelector(null,targetCoverage) : new AllReadsSelector()); + readSelectors.put(sample.getID(),downsamplingMethod.type == DownsampleType.BY_SAMPLE ? new NRandomReadSelector(null,targetCoverage) : new AllReadsSelector()); } samplePartitioner = new SamplePartitioner(readSelectors); @@ -640,7 +640,7 @@ public class LocusIteratorByState extends LocusIterator { samplePartitioner.complete(); for(Sample sample: samples) { - ReadSelector aggregator = samplePartitioner.getSelectedReads(sample.getId()); + ReadSelector aggregator = samplePartitioner.getSelectedReads(sample.getID()); Collection newReads = new ArrayList(aggregator.getSelectedReads()); diff --git a/public/java/src/org/broadinstitute/sting/gatk/samples/Sample.java b/public/java/src/org/broadinstitute/sting/gatk/samples/Sample.java index c37796bb6..f92533f08 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/samples/Sample.java +++ b/public/java/src/org/broadinstitute/sting/gatk/samples/Sample.java @@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.samples; import org.broadinstitute.sting.utils.exceptions.StingException; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -13,23 +14,16 @@ import java.util.Map; * Time: 3:31:38 PM */ public class Sample implements java.io.Serializable { - private final static String MOTHER = "mother"; - private final static String FATHER = "father"; - private final static String GENDER = "gender"; - private final static String POPULATION = "population"; - private final static String FAMILY = "familyId"; - private final static String AFFECTION = "affection"; - private final static String QUANT_TRAIT = "quantTrait"; - - private final String id; - - private boolean hasSampleFileEntry = false; // true if this sample has an entry in a sample file + final private String familyID, paternalID, maternalID; + final private Sample.Gender gender; + final private double quantitativePhenotype; + final private Sample.Affection affection; + final private String population; + final private String ID; + final private SampleDataSource dataSource; private boolean hasSAMFileEntry = false; // true if this sample has an entry in the SAM file - - private HashMap properties = new HashMap(); - - private HashMap relationships = new HashMap(); + private Map properties = new HashMap(); public enum Gender { MALE, @@ -47,26 +41,28 @@ public class Sample implements java.io.Serializable { /** A quantitative trait: value of the trait is stored elsewhere */ QUANTITATIVE } + public final static double UNSET_QUANTITIATIVE_TRAIT_VALUE = Double.NaN; - public Sample(String id) { -/* if (id == null) { - throw new StingException("Error creating sample: sample ID cannot be null"); - }*/ - this.id = id; + public Sample(final String ID, final SampleDataSource dataSource, + final String familyID, final String paternalID, final String maternalID, + final Gender gender, final double quantitativePhenotype, final Affection affection, + final String population) { + this.familyID = familyID; + this.paternalID = paternalID; + this.maternalID = maternalID; + this.gender = gender; + this.quantitativePhenotype = quantitativePhenotype; + this.affection = affection; + this.population = population; + this.ID = ID; + this.dataSource = dataSource; } - public String getId() { - return this.id; - } - - public Map getProperties() { - return properties; - } - - @Deprecated - public void setSampleFileEntry(boolean value) { - this.hasSampleFileEntry = value; + public Sample(String id, SampleDataSource dataSource) { + this(id, dataSource, + null, null, null, + Gender.UNKNOWN, UNSET_QUANTITIATIVE_TRAIT_VALUE, Affection.UNKNOWN, null); } @Deprecated @@ -79,58 +75,39 @@ public class Sample implements java.io.Serializable { this.hasSAMFileEntry = value; } - /** - * Get one property - * @param key key of property - * @return value of property as generic object - */ - public Object getProperty(String key) { - return properties.get(key); + // ------------------------------------------------------------------------------------- + // + // standard property getters + // + // ------------------------------------------------------------------------------------- + + public String getID() { + return ID; } - /** - * Set a property - * If property already exists, it is overwritten - * @param key key of property - * @param value object to be stored in properties array - */ - public void setProperty(String key, Object value) { - if (relationships.containsKey(key)) { - throw new StingException("The same key cannot exist as a property and a relationship"); - } - - if (key.equals(GENDER) && value.getClass() != Gender.class) { - throw new StingException("'gender' property must be of type Sample.Gender"); - } - - if (key.equals(POPULATION) && value.getClass() != String.class) { - throw new StingException("'population' property must be of type String"); - } - - properties.put(key, value); + public String getFamilyID() { + return familyID; } - /** - * Get one relationship - * @param key of relationship - * @return Sample object that this relationship points to - */ - public Sample getRelationship(String key) { - return relationships.get(key); + public String getPaternalID() { + return paternalID; } - /** - * Set one relationship - * If already set, it is overwritten - * @param key key of the relationship - * @param value Sample object this relationship points to - */ - public void setRelationship(String key, Sample value) { - if (properties.containsKey(key)) { - throw new StingException("The same key cannot exist as a property and a relationship"); - } - relationships.put(key, value); + public String getMaternalID() { + return maternalID; + } + + public Affection getAffection() { + return affection; + } + + public boolean hasQuantitativeTrait() { + return affection == Affection.QUANTITATIVE; + } + + public double getQuantitativePhenotype() { + return quantitativePhenotype; } /** @@ -138,7 +115,7 @@ public class Sample implements java.io.Serializable { * @return sample object with relationship mother, if exists, or null */ public Sample getMother() { - return getRelationship(MOTHER); + return dataSource.getSampleById(maternalID); } /** @@ -146,7 +123,7 @@ public class Sample implements java.io.Serializable { * @return sample object with relationship father, if exists, or null */ public Sample getFather() { - return getRelationship(FATHER); + return dataSource.getSampleById(paternalID); } /** @@ -154,29 +131,48 @@ public class Sample implements java.io.Serializable { * @return property of key "gender" - must be of type Gender */ public Gender getGender() { - return (Gender) properties.get(GENDER); + return gender; } public String getPopulation() { - return (String) properties.get(POPULATION); + return population; } public String getFamilyId() { - return (String) properties.get(FAMILY); + return familyID; } /** * @return True if sample is male, false if female, unknown, or null */ public boolean isMale() { - return properties.get(GENDER) == Gender.MALE; + return getGender() == Gender.MALE; } /** * @return True if sample is female, false if male, unknown or null */ public boolean isFemale() { - return properties.get(GENDER) == Gender.MALE; + return getGender() == Gender.MALE; + } + + // ------------------------------------------------------------------------------------- + // + // code for working with additional -- none standard -- properites + // + // ------------------------------------------------------------------------------------- + + public Map getExtraProperties() { + return Collections.unmodifiableMap(properties); + } + + /** + * Get one property + * @param key key of property + * @return value of property as generic object + */ + public Object getExtraPropertyValue(final String key) { + return properties.get(key); } /** @@ -184,7 +180,7 @@ public class Sample implements java.io.Serializable { * @param key property key * @return true if sample has this property (even if its value is null) */ - public boolean hasProperty(String key) { + public boolean hasExtraProperty(String key) { return properties.containsKey(key); } @@ -196,17 +192,14 @@ public class Sample implements java.io.Serializable { Sample sample = (Sample) o; if (hasSAMFileEntry != sample.hasSAMFileEntry) return false; - if (hasSampleFileEntry != sample.hasSampleFileEntry) return false; - if (id != null ? !id.equals(sample.id) : sample.id != null) return false; + if (ID != null ? !ID.equals(sample.ID) : sample.ID != null) return false; if (properties != null ? !properties.equals(sample.properties) : sample.properties != null) return false; - if (relationships != null ? !relationships.equals(sample.relationships) : sample.relationships != null) - return false; return true; } @Override public int hashCode() { - return id != null ? id.hashCode() : "".hashCode(); + return ID != null ? ID.hashCode() : "".hashCode(); } } diff --git a/public/java/src/org/broadinstitute/sting/gatk/samples/SampleDataSource.java b/public/java/src/org/broadinstitute/sting/gatk/samples/SampleDataSource.java index d3c59d9f4..f4855b27f 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/samples/SampleDataSource.java +++ b/public/java/src/org/broadinstitute/sting/gatk/samples/SampleDataSource.java @@ -46,12 +46,6 @@ public class SampleDataSource { */ private HashMap sampleAliases = new HashMap(); - /** - * While loading sample files, we must be aware of "special" properties and relationships that are always allowed - */ - public static final String[] specialProperties = new String[] {"familyId", "population", "gender"}; - public static final String[] specialRelationships = new String[] {"mother", "father"}; - /** * Constructor takes both a SAM header and sample files because the two must be integrated. * @param header SAMFileHeader that has been created for this analysis @@ -63,8 +57,7 @@ public class SampleDataSource { // create empty sample object for each sample referenced in the SAM header for (String sampleName : SampleUtils.getSAMFileSamples(header)) { if (!hasSample(sampleName)) { - Sample newSample = new Sample(sampleName); - newSample.setSAMFileEntry(true); + Sample newSample = new Sample(sampleName, this); samples.put(sampleName, newSample); } } @@ -78,7 +71,7 @@ public class SampleDataSource { } public SampleDataSource() { - samples.put(null, new Sample(null)); + samples.put(null, new Sample(null, this)); } /** @@ -87,7 +80,7 @@ public class SampleDataSource { public void addSamplesFromSAMHeader(SAMFileHeader header) { for (String sampleName : SampleUtils.getSAMFileSamples(header)) { if (!hasSample(sampleName)) { - Sample newSample = new Sample(sampleName); + Sample newSample = new Sample(sampleName, this); newSample.setSAMFileEntry(true); samples.put(sampleName, newSample); } @@ -151,9 +144,9 @@ public class SampleDataSource { // // try { // // step 1: add the sample if it doesn't already exist -// Sample sample = getSampleById(sampleParser.getId()); +// Sample sample = getSampleById(sampleParser.getID()); // if (sample == null) { -// sample = new Sample(sampleParser.getId()); +// sample = new Sample(sampleParser.getID()); // } // addSample(sample); // sample.setSampleFileEntry(true); @@ -207,7 +200,7 @@ public class SampleDataSource { // // // next check that there isn't already a conflicting property there // if (sample.getRelationship(relationship) != null) { -// if (sample.getRelationship(relationship).getId() != sampleParser.getProperties().get(relationship)) { +// if (sample.getRelationship(relationship).getID() != sampleParser.getProperties().get(relationship)) { // throw new StingException(relationship + " is a conflicting relationship!"); // } // // if the relationship is already set - and consistent with what we're reading now - no need to continue @@ -222,7 +215,7 @@ public class SampleDataSource { // } // } catch (Exception e) { // throw new StingException("An error occurred while loading this sample from the sample file: " + -// sampleParser.getId(), e); +// sampleParser.getID(), e); // } // } // } @@ -377,7 +370,7 @@ public class SampleDataSource { * @param sample to be added */ private void addSample(Sample sample) { - samples.put(sample.getId(), sample); + samples.put(sample.getID(), sample); } /** @@ -496,7 +489,7 @@ public class SampleDataSource { public Set getSamplesWithProperty(String key) { HashSet toReturn = new HashSet(); for (Sample s : samples.values()) { - if (s.hasProperty(key)) + if (s.hasExtraProperty(key)) toReturn.add(s); } return toReturn; @@ -513,7 +506,7 @@ public class SampleDataSource { public Set getSamplesWithProperty(String key, String value) { Set toReturn = getSamplesWithProperty(key); for (Sample s : toReturn) { - if (!s.getProperty(key).equals(value)) + if (!s.getExtraPropertyValue(key).equals(value)) toReturn.remove(s); } return toReturn; @@ -522,7 +515,7 @@ public class SampleDataSource { public Sample getOrCreateSample(String id) { Sample sample = getSampleById(id); if (sample == null) { - sample = new Sample(id); + sample = new Sample(id, this); addSample(sample); } return sample; @@ -568,16 +561,10 @@ public class SampleDataSource { Set samplesWithProperty = new HashSet(); for (String sampleName : context.getSampleNames()) { Sample s = samples.get(sampleName); - if (s != null && s.hasProperty(key) && s.getProperty(key).equals(value)) + if (s != null && s.hasExtraProperty(key) && s.getExtraPropertyValue(key).equals(value)) samplesWithProperty.add(sampleName); } Map genotypes = context.getGenotypes(samplesWithProperty); return context.subContextFromGenotypes(genotypes.values()); } - - public static SampleDataSource createEmptyDataSource() { - SAMFileHeader header = new SAMFileHeader(); - return new SampleDataSource(header, null); - } - } diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java index 10261112c..ef791f12f 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java @@ -30,6 +30,8 @@ import org.apache.log4j.Logger; import org.broadinstitute.sting.gatk.CommandLineGATK; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.gatk.filters.MalformedReadFilter; +import org.broadinstitute.sting.gatk.samples.Sample; +import org.broadinstitute.sting.gatk.samples.SampleDataSource; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.baq.BAQ; import org.broadinstitute.sting.utils.collections.Pair; @@ -87,6 +89,14 @@ public abstract class Walker { return getToolkit().getMasterSequenceDictionary(); } + protected SampleDataSource getSampleDB() { + return getToolkit().getSampleDB(); + } + + protected Sample getSampleByID(final String id) { + return getToolkit().getSampleDB().getSampleById(id); + } + /** * (conceptual static) method that states whether you want to see reads piling up at a locus * that contain a deletion at the locus. diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java index 87695077d..ecc4ad793 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java @@ -247,7 +247,7 @@ public class ProduceBeagleInputWalker extends RodWalker { Map preferredGenotypes = preferredVC.getGenotypes(); Map otherGenotypes = goodSite(otherVC) ? otherVC.getGenotypes() : null; for ( String sample : samples ) { - boolean isMaleOnChrX = CHECK_IS_MALE_ON_CHR_X && getToolkit().getSampleById(sample).isMale(); + boolean isMaleOnChrX = CHECK_IS_MALE_ON_CHR_X && getSampleByID(sample).isMale(); Genotype genotype; boolean isValidation; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalker.java index 32875a098..1e2d40271 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalker.java @@ -227,9 +227,9 @@ public class CallableLociWalker extends LocusWalker impl for (SAMRecord read : reads) { // get the sample - Sample sample = getToolkit().getSampleByRead(read); + Sample sample = getSampleDB().getSampleByRead(read); if (sample == null) return 1; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountMalesWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountMalesWalker.java index 3c93f0786..2d89a7d44 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountMalesWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountMalesWalker.java @@ -16,7 +16,7 @@ import org.broadinstitute.sting.gatk.walkers.Requires; @Requires({DataSource.READS, DataSource.REFERENCE}) public class CountMalesWalker extends ReadWalker { public Integer map(ReferenceContext ref, SAMRecord read, ReadMetaDataTracker tracker) { - Sample sample = getToolkit().getSampleByRead(read); + Sample sample = getSampleDB().getSampleByRead(read); return sample.isMale() ? 1 : 0; } diff --git a/public/java/src/org/broadinstitute/sting/utils/MendelianViolation.java b/public/java/src/org/broadinstitute/sting/utils/MendelianViolation.java index 7a044e4d1..a87a73a2d 100755 --- a/public/java/src/org/broadinstitute/sting/utils/MendelianViolation.java +++ b/public/java/src/org/broadinstitute/sting/utils/MendelianViolation.java @@ -88,9 +88,9 @@ public class MendelianViolation { * @param minGenotypeQualityP - the minimum phred scaled genotype quality score necessary to asses mendelian violation */ public MendelianViolation(Sample sample, double minGenotypeQualityP) { - sampleMom = sample.getMother().getId(); - sampleDad = sample.getFather().getId(); - sampleChild = sample.getId(); + sampleMom = sample.getMother().getID(); + sampleDad = sample.getFather().getID(); + sampleChild = sample.getID(); minGenotypeQuality = minGenotypeQualityP; } @@ -102,13 +102,13 @@ public class MendelianViolation { */ public MendelianViolation(GenomeAnalysisEngine engine, double minGenotypeQualityP) { boolean gotSampleInformation = false; - Collection samples = engine.getSamples(); + Collection samples = engine.getSampleDB().getSamples(); // Iterate through all samples in the sample_metadata file but we really can only take one. for (Sample sample : samples) { if (sample.getMother() != null && sample.getFather() != null) { - sampleMom = sample.getMother().getId(); - sampleDad = sample.getFather().getId(); - sampleChild = sample.getId(); + sampleMom = sample.getMother().getID(); + sampleDad = sample.getFather().getID(); + sampleChild = sample.getID(); minGenotypeQuality = minGenotypeQualityP; gotSampleInformation = true; break; // we can only deal with one trio information diff --git a/public/java/src/org/broadinstitute/sting/utils/pileup/AbstractReadBackedPileup.java b/public/java/src/org/broadinstitute/sting/utils/pileup/AbstractReadBackedPileup.java index 92915f590..3bc325cea 100644 --- a/public/java/src/org/broadinstitute/sting/utils/pileup/AbstractReadBackedPileup.java +++ b/public/java/src/org/broadinstitute/sting/utils/pileup/AbstractReadBackedPileup.java @@ -555,7 +555,7 @@ public abstract class AbstractReadBackedPileup tracker = (PerSamplePileupElementTracker)pileupElementTracker; Collection sampleNames = new HashSet(); for (Sample sample : tracker.getSamples()) { - sampleNames.add(sample.getId()); + sampleNames.add(sample.getID()); } return sampleNames; } @@ -700,7 +700,7 @@ public abstract class AbstractReadBackedPileup extends PileupElem Sample sample = entry.getKey(); AbstractReadBackedPileup pileupBySample = entry.getValue(); pileup.put(sample,pileupBySample.pileupElementTracker); - sampleNames.put(sample.getId(), sample); + sampleNames.put(sample.getID(), sample); } } @@ -105,7 +105,7 @@ class PerSamplePileupElementTracker extends PileupElem public void addElements(final Sample sample, PileupElementTracker elements) { pileup.put(sample,elements); - sampleNames.put(sample.getId(), sample); + sampleNames.put(sample.getID(), sample); size += elements.size(); } diff --git a/public/java/test/org/broadinstitute/sting/gatk/samples/SampleDataSourceUnitTest.java b/public/java/test/org/broadinstitute/sting/gatk/samples/SampleDataSourceUnitTest.java index 390ed95ae..61aed7b34 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/samples/SampleDataSourceUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/samples/SampleDataSourceUnitTest.java @@ -149,8 +149,8 @@ public class SampleDataSourceUnitTest extends BaseTest { Iterator i = ceuSamples.iterator(); ArrayList sampleNames = new ArrayList(); - sampleNames.add(i.next().getId()); - sampleNames.add(i.next().getId()); + sampleNames.add(i.next().getID()); + sampleNames.add(i.next().getID()); Assert.assertTrue(sampleNames.contains("sampleA")); Assert.assertTrue(sampleNames.contains("sampleB")); } @@ -191,8 +191,8 @@ public class SampleDataSourceUnitTest extends BaseTest { // make sure both samples are included Iterator i = set.iterator(); ArrayList sampleNames = new ArrayList(); - sampleNames.add(i.next().getId()); - sampleNames.add(i.next().getId()); + sampleNames.add(i.next().getID()); + sampleNames.add(i.next().getID()); Assert.assertTrue(sampleNames.contains("NA123")); Assert.assertTrue(sampleNames.contains("NA456")); } diff --git a/public/java/test/org/broadinstitute/sting/gatk/samples/SampleUnitTest.java b/public/java/test/org/broadinstitute/sting/gatk/samples/SampleUnitTest.java index 7f9a57f08..ca777200b 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/samples/SampleUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/samples/SampleUnitTest.java @@ -55,7 +55,7 @@ public class SampleUnitTest extends BaseTest { */ @Test() public void specialGettersTest() { - Assert.assertTrue(sampleC.getId().equals("sampleC")); + Assert.assertTrue(sampleC.getID().equals("sampleC")); Assert.assertTrue(sampleC.getPopulation().equals("pop1")); Assert.assertTrue(sampleC.isMale()); Assert.assertFalse(sampleA.isMale()); // sample A doesn't have a gender, so this should be false diff --git a/public/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupUnitTest.java b/public/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupUnitTest.java index d982d54a2..2b9ff7113 100644 --- a/public/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupUnitTest.java @@ -168,9 +168,9 @@ public class ReadBackedPileupUnitTest { Sample sample2 = new Sample("sample2"); SAMReadGroupRecord readGroupOne = new SAMReadGroupRecord("rg1"); - readGroupOne.setSample(sample1.getId()); + readGroupOne.setSample(sample1.getID()); SAMReadGroupRecord readGroupTwo = new SAMReadGroupRecord("rg2"); - readGroupTwo.setSample(sample2.getId()); + readGroupTwo.setSample(sample2.getID()); SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1,1,1000); header.addReadGroup(readGroupOne); @@ -191,7 +191,7 @@ public class ReadBackedPileupUnitTest { Assert.assertEquals(sample1Pileup.size(),1,"Sample 1 pileup has wrong number of elements"); Assert.assertEquals(sample1Pileup.getReads().get(0),read1,"Sample 1 pileup has incorrect read"); - ReadBackedPileup sample2Pileup = pileup.getPileupForSampleName(sample2.getId()); + ReadBackedPileup sample2Pileup = pileup.getPileupForSampleName(sample2.getID()); Assert.assertEquals(sample2Pileup.size(),1,"Sample 2 pileup has wrong number of elements"); Assert.assertEquals(sample2Pileup.getReads().get(0),read2,"Sample 2 pileup has incorrect read");