Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacobo Coll Moragón j-coll

  • Zetta Genomics
  • Cambridge, UK
View GitHub Profile
View deploy_opencga_local.sh
#!/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 Sep 27, 2017
Migration script for Variants opencga-storage-mongodb
View opencga_storage_v1.1.x_to_1.2.0.js
// 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("================================================================================");
View opencga_574_add_studies_field_to_stage.js
// 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 = [];
View detect_overlapping_files_549.js
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 Jun 16, 2017 — forked from pfurio/migrateCollection.js
Base migration script
View migrateCollection.js
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 Feb 24, 2017
Add _gn_so field in Variants collection. Related with opencb/opencga#500
View add_gn_so_field_500.js
// 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 Jan 23, 2017
Repair opencga-storage-mongodb variants database due to opencb/opencga#504
View repair_mongodb_opencga_504.js
// 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 Jan 19, 2017
Tomcat8 should run with the same user that installs OpenCGA.
View Tomcat8_user.md

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
View drop_file.js
// 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 Jan 25, 2017
Update to HDP-2.5.3.0
View HDP-CHANGES-REAL.txt
# 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