View audit_login.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from pymongo import MongoClient | |
from bson import ObjectId | |
import datetime | |
import argparse | |
parser = argparse.ArgumentParser(description='Get the number of times each user have logged in during a period of time.') | |
parser.add_argument('host', metavar='host', help='Mongo host and port. Example: localhost:27017.') | |
# parser.add_argument('database', metavar='database', help='Mongo database name. Example: opencga_catalog.') |
View #Opencga migration 1.1.x to 1.2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Load the function from https://gist.github.com/pfurio/f7cd90af08e0073699f0beeeef1958ba | |
// 2. Load all the scripts present in the gist in the CATALOG database |
View removeSessions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extracted from https://stackoverflow.com/questions/3066586/get-string-in-yyyymmdd-format-from-js-date-object | |
Date.prototype.opencgaDate = function() { | |
// We will get the current day minus 7 days | |
this.setDate(this.getDate() - 7); | |
var mm = this.getMonth() + 1; // getMonth() is zero-based | |
var dd = this.getDate(); | |
return [this.getFullYear(), | |
(mm>9 ? '' : '0') + mm, | |
(dd>9 ? '' : '0') + dd, |
View opencga-1.1.0-migration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use migration script https://gist.github.com/pfurio/f7cd90af08e0073699f0beeeef1958ba | |
/* | |
Migrate NUMERIC variables to DOUBLE https://github.com/opencb/opencga/issues/545 | |
*/ | |
// This function receives an array of variables (not variableSet), | |
// and will modify NUMERIC variables to DOUBLE recursively | |
function modifyNumeric(variables) { | |
var modified = false; |
View permissionMigration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
migrateCollection("metadata", {}, {config: 1, acl: 1}, function (bulk, doc) { | |
var id = doc._id; | |
var permissions = ["VIEW_FILE_HEADERS", "VIEW_FILE_CONTENTS", "VIEW_FILES", "WRITE_FILES", "VIEW_JOBS", "WRITE_JOBS"]; | |
doc.acl[0].permissions = permissions; | |
doc.config.acl[0].permissions = permissions; | |
bulk.find({_id: id}).update({$set: {"acl": doc.acl, "config.acl": doc.config.acl}}); | |
}); | |
View migrateCollection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
bulk.execute(); |
View readPeaks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Author: Pedro Furió Tarí | |
# Data: 06/05/2013 | |
# | |
# This script will take a sorted and indexed bam file and return different text files with the counts | |
# Useful when doing a trimming step for pair-end. After trimming, we have to make sure that we have the pairs correctly paired | |
import getopt, sys, os.path | |
import pysam |