Quick patch to fix the sample code. It wasn't actually initializing the sample data source, so I added a call to initializeSampleDataSource() in GenomeAnalysisEngine. I think there was just an error resolving the versions of GenomeAnalysisEngine
Also added a new error message that I thought would be helpful... git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4301 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
a10b2a00a5
commit
bc12055fcf
|
|
@ -381,6 +381,8 @@ public class GenomeAnalysisEngine {
|
|||
validateSuppliedReferenceAgainstWalker(my_walker, argCollection);
|
||||
referenceDataSource = openReferenceSequenceFile(argCollection.referenceFile);
|
||||
|
||||
initializeSampleDataSource();
|
||||
|
||||
if (argCollection.DBSNPFile != null) bindConvenienceRods(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME, "dbsnp", argCollection.DBSNPFile);
|
||||
|
||||
RMDTrackBuilder manager = new RMDTrackBuilder();
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ public class SampleDataSource {
|
|||
try {
|
||||
parser = (SampleFileParser) yaml.load(reader);
|
||||
}
|
||||
catch (Exception e) { // TODO: should we have more granular exception here?
|
||||
catch (Exception e) {
|
||||
throw new StingException("There was a syntactic error with the YAML in sample file " + sampleFile.getAbsolutePath(), e);
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +149,7 @@ public class SampleDataSource {
|
|||
// loop through each sample in the file - a SampleParser stores an object that will become a Sample
|
||||
for (SampleParser sampleParser : parser.getSamples()) {
|
||||
|
||||
try {
|
||||
// step 1: add the sample if it doesn't already exist
|
||||
Sample sample = getSampleById(sampleParser.getId());
|
||||
if (sample == null) {
|
||||
|
|
@ -219,6 +220,10 @@ public class SampleDataSource {
|
|||
saveRelationship(sample, relationship, relativeId);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new StingException("An error occurred while loading this sample from the sample file: " +
|
||||
sampleParser.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -326,9 +331,13 @@ public class SampleDataSource {
|
|||
else if (value != null) {
|
||||
throw new StingException("'gender' property must be male, female, or unknown.");
|
||||
}
|
||||
value = null;
|
||||
}
|
||||
sample.setProperty(key, value);
|
||||
try {
|
||||
sample.setProperty(key, value);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new StingException("Could not save property " + key, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.broadinstitute.sting.playground.sample;
|
|||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.datasources.sample.Sample;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.TreeReducible;
|
||||
|
|
@ -11,27 +12,32 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Walks over the input data set, calculating the total number of covered loci for diagnostic purposes.
|
||||
* Simplest example of a locus walker.
|
||||
* Extends locus walker to print how many reads there are at each locus, by population
|
||||
*/
|
||||
public class CountLociByPopulationWalker extends LocusWalker<Integer, Long> implements TreeReducible<Long> {
|
||||
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
|
||||
// in this HashMap, we'll keep count of how many
|
||||
HashMap<String, Integer> count = new HashMap<String, Integer>();
|
||||
|
||||
ArrayList<SAMRecord> reads = (ArrayList) context.getBasePileup().getReads();
|
||||
|
||||
for (SAMRecord read : reads) {
|
||||
String population = getToolkit().getSampleByRead(read).getPopulation();
|
||||
if (!count.containsKey(population)) {
|
||||
count.put(population, 1);
|
||||
|
||||
// get the sample
|
||||
Sample sample = getToolkit().getSampleByRead(read);
|
||||
if (sample == null)
|
||||
return 1;
|
||||
|
||||
if (!count.containsKey(sample.getPopulation())) {
|
||||
count.put(sample.getPopulation(), 1);
|
||||
}
|
||||
count.put(population, count.get(population) + 1);
|
||||
count.put(sample.getPopulation(), count.get(sample.getPopulation()) + 1);
|
||||
}
|
||||
|
||||
System.out.println("\n\n\n***** LOCUS: " + ref.toString() + " *****");
|
||||
System.out.println("\n\n\n***** LOCUS: " + ref.getLocus().toString() + " *****");
|
||||
for (String population : count.keySet()) {
|
||||
System.out.println(String.format("%s | %d\n", population, count.get(population)));
|
||||
System.out.println(String.format("%s | %d", population, count.get(population)));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue