Insert the ROD filename into MongoDB as part of the primary key
This commit is contained in:
parent
bb8a6e9b0a
commit
1f7c628796
|
|
@ -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<Integer, Integer> {
|
|||
protected Mongo mongo;
|
||||
protected DBCollection mongoCollection;
|
||||
|
||||
private String RODFileName;
|
||||
|
||||
@Override
|
||||
public void initialize()
|
||||
{
|
||||
|
|
@ -46,15 +49,20 @@ public class InsertRODsWalker extends RodWalker<Integer, Integer> {
|
|||
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<Integer, Integer> {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1221,7 +1221,7 @@ public class VariantContext implements Feature { // to enable tribble integratio
|
|||
this.getGenotypes());
|
||||
}
|
||||
|
||||
public List<BasicDBObject> toMongoDB() {
|
||||
public List<BasicDBObject> toMongoDB(String sourceROD) {
|
||||
List<BasicDBObject> vcDocs = new ArrayList<BasicDBObject>();
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue