diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/InsertRODsWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/InsertRODsWalker.java index 55790bd3f..199126a7c 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/InsertRODsWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/InsertRODsWalker.java @@ -18,6 +18,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.utils.variantcontext.VariantContext; +import java.io.File; import java.io.PrintStream; /** @@ -38,6 +39,8 @@ public class InsertRODsWalker extends RodWalker { protected Mongo mongo; protected DBCollection mongoCollection; + private String RODFileName; + @Override public void initialize() { @@ -46,15 +49,20 @@ public class InsertRODsWalker extends RodWalker { DB mongoDb = mongo.getDB(MONGO_DB_NAME); mongoCollection = mongoDb.getCollection(MONGO_VC_COLLECTION); + RODFileName = input.getSource(); + int lastSep = RODFileName.lastIndexOf(File.separator); + RODFileName = RODFileName.substring(lastSep + 1); + // set up indices mongoCollection.ensureIndex("location"); mongoCollection.ensureIndex("sample"); + mongoCollection.ensureIndex("sourceROD"); mongoCollection.ensureIndex("contig"); mongoCollection.ensureIndex("start"); mongoCollection.ensureIndex("stop"); // set up primary key - mongoCollection.ensureIndex(new BasicDBObject("location", 1).append("sample", 1), new BasicDBObject("unique", 1)); + mongoCollection.ensureIndex(new BasicDBObject("location", 1).append("sample", 1).append("sourceROD", 1), new BasicDBObject("unique", 1)); } catch (MongoException e) {} @@ -82,7 +90,7 @@ public class InsertRODsWalker extends RodWalker { for ( Feature feature : tracker.getValues(Feature.class, context.getLocation()) ) { if ( feature instanceof VariantContext ) { VariantContext vc = (VariantContext) feature; - for (BasicDBObject vcForMongo : vc.toMongoDB()) { + for (BasicDBObject vcForMongo : vc.toMongoDB(RODFileName)) { mongoCollection.insert(vcForMongo); } } diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java index 155f5445b..ae88b4539 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java @@ -1221,7 +1221,7 @@ public class VariantContext implements Feature { // to enable tribble integratio this.getGenotypes()); } - public List toMongoDB() { + public List toMongoDB(String sourceROD) { List vcDocs = new ArrayList(); for (Genotype genotype : this.getGenotypes()) { BasicDBObject vcDoc = new BasicDBObject(); @@ -1233,6 +1233,7 @@ public class VariantContext implements Feature { // to enable tribble integratio vcDoc.put("error", this.getLog10PError()); vcDoc.put("sample", genotype.getSampleName()); vcDoc.put("source", this.getSource()); + vcDoc.put("sourceROD", sourceROD); vcDoc.put("type", this.getType().toString()); Integer alleleIndex = 0;