Skip to content

Instantly share code, notes, and snippets.

View j-coll's full-sized avatar

Jacobo Coll Moragón j-coll

  • Zetta Genomics
  • Cambridge, UK
View GitHub Profile
#!/bin/bash
name=${1:opencga}
if [ "$name" != "opencga" ]; then
name=opencga_$name
fi
echo "Installation name :" $name
echo "Clean installation dir"
@j-coll
j-coll / opencga_storage_v1.1.x_to_1.2.0.js
Last active September 27, 2017 10:17
Migration script for Variants opencga-storage-mongodb
// Use migration script https://gist.github.com/j-coll/c2b81a7ff8392ec6b5208b5a8bf0d3d3
// load("utils/migrateCollection.js")
/**
* #192 -> Collect genotypes
* #626 -> Populate alts into stage collection
**/
if ( db.getCollection("variants").exists() == null ) {
print("================================================================================");
// Use migration script https://gist.github.com/j-coll/c2b81a7ff8392ec6b5208b5a8bf0d3d3
var otherKeys = {
_id : "",
end : "",
ref : "",
alt : ""
};
migrateCollection("stage", {"_i" : {"$exists" : false} }, {}, function(bulk, doc) {
var _i = [];
function migrateCollection(collection, query, projection, migrateFunc) {
var bulk = db.getCollection(collection).initializeOrderedBulkOp();
var count = 0;
var bulkSize = 500;
db.getCollection(collection).find(query,projection).forEach(function(doc) {
migrateFunc(bulk, doc);
if ( bulk.nUpdateOps + bulk.nInsertOps + bulk.nRemoveOps >= bulkSize ) {
count += bulk.nUpdateOps + bulk.nInsertOps + bulk.nRemoveOps;
print("Execute bulk! " + count);
@j-coll
j-coll / migrateCollection.js
Last active June 16, 2017 15:25 — forked from pfurio/migrateCollection.js
Base migration script
function migrateCollectionDifferentCollection(inputCollection, outputCollection, query, projection, migrateFunc) {
var bulk = db.getCollection(outputCollection).initializeOrderedBulkOp();
var count = 0;
var bulkSize = 500;
db.getCollection(inputCollection).find(query,projection).forEach(function(doc) {
migrateFunc(bulk, doc);
if ( bulk.nUpdateOps + bulk.nInsertOps + bulk.nRemoveOps >= bulkSize ) {
count += bulk.nUpdateOps + bulk.nInsertOps + bulk.nRemoveOps;
print("Execute bulk! " + count);
bulk.execute();
@j-coll
j-coll / add_gn_so_field_500.js
Last active February 24, 2017 14:33
Add _gn_so field in Variants collection. Related with opencb/opencga#500
// Use migration script https://gist.github.com/pfurio/f7cd90af08e0073699f0beeeef1958ba
migrateCollection("variants", {"annotation.ct":{$exists:1}, "annotation._gn_so":{$exists:false}}, {"annotation.ct":1}, function (bulk, doc) {
var id = doc._id;
var fields = ["gn", "ensg", "enst", "uni_a", "uni_n"];
var gn_so_obj = {}; /* Use as set */
for (var i in doc.annotation[0].ct) {
var ct = doc.annotation[0].ct[i];
for (var so_idx in ct.so) {
@j-coll
j-coll / repair_mongodb_opencga_504.js
Last active January 23, 2017 14:11
Repair opencga-storage-mongodb variants database due to opencb/opencga#504
// Generic migration utility method
function migrateCollection(collection, query, projection, migrateFunc) {
var bulk = db.getCollection(collection).initializeOrderedBulkOp();
var count = 0;
var bulkSize = 500;
db.getCollection(collection).find(query,projection).forEach(function(doc) {
migrateFunc(bulk, doc);
@j-coll
j-coll / Tomcat8_user.md
Created January 19, 2017 11:58
Tomcat8 should run with the same user that installs OpenCGA.

Tomcat8 should run with the same user that installs OpenCGA. We will assume that OpenCGA will be installed with user opencga. Run the following to set Tomcat8 to run with user opencga.

cd /var/lib/tomcat8/
# Change owner and group of every folder following links
sudo chown -RL opencga:opencga ./*
sudo service tomcat8 stop
// mongo opencga_user_project
/*
var studyId = ??;
var fileIds = [??];
var sampleIds = [??];
*/
function dropFiles(studyId, fileIds, sampleIds) {
db.variants.update(
{
@j-coll
j-coll / HDP-CHANGES-REAL.txt
Last active January 25, 2017 12:24
Update to HDP-2.5.3.0
# Apache phoenix 4.7.0.2.5.0.0-1245 (from HDP-2.5.0) is based on Apache Phoenix 4.7.0-HBase-1.1
# These are ALL the changes on top of Apache Phoenix 4.7.0-HBase-1.1
#
# cd phoenix
# git checkout v4.7.0-HBase-1.1
# git log --pretty=oneline | cut -d " " -f 2 | grep "PHOENIX-" | tr -d ":.[]" | sort | uniq > issues_phoenix-4.7-hbase-1.1.txt
#
# cd phoenix-release
# git checkout HDP-2.5.3.0-tag
# git log --pretty=oneline | cut -d " " -f 2 | grep "PHOENIX-" | tr -d ":.[]" | sort | uniq > issues_hdp2.5.0.txt