Skip to content

Instantly share code, notes, and snippets.

@j-coll
Created January 9, 2017 14:51
Show Gist options
  • Save j-coll/747d3e9f73267f49ca19d3c8f0b58c58 to your computer and use it in GitHub Desktop.
Save j-coll/747d3e9f73267f49ca19d3c8f0b58c58 to your computer and use it in GitHub Desktop.
// mongo opencga_user_project
/*
var studyId = ??;
var fileIds = [??];
var sampleIds = [??];
*/
function dropFiles(studyId, fileIds, sampleIds) {
db.variants.update(
{
"studies" : {
$elemMatch: {
"sid" : studyId,
"files.fid" : { $in : fileIds }
}
}
}, {
$pull:{
"studies.$.files":{fid:{$in:fileIds}},
"studies.$.gt.?/?" : {$in:sampleIds},
"studies.$.gt.0/1" : {$in:sampleIds},
"studies.$.gt.1/1" : {$in:sampleIds} // Add other genotypes
}
} , {multi:true})
db.studies.update({"_id":studyId},{$pull:{"indexedFiles":{$in:fileIds}}})
db.files.drop({"fileId":{$in:fileIds}})
// Remove from stage collection
}
// mongo opencga_catalog
db.file.update({"_id":{$in:fileIds}}, {$set:{"index.status":"NONE"}}, {multi:true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment