This file contains hidden or 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
| // remove field from all samples | |
| db.getCollection('samples').update({}, {'$unset': {'viterbi_haplotypes': 1}}, {multi: true}) | |
| // initialize fields in all samples | |
| db.getCollection('samples').update({}, {'$set': {'viterbi_haplotypes': {}}}, {multi: true}) | |
| // how to slice without getting everything you don't care about | |
| db.getCollection('samples').find( | |
| {'_id': ObjectId("55e9cf1a6606af0e6e5cb5a1")}, | |
| { |
This file contains hidden or 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
| import csv | |
| import requests | |
| def build_ensembl_biomart_dict(dataset_name, key_attr, val_attr): | |
| # see http://ensembl.org/biomart/martview/ for the web application | |
| biomart_request_url_template = \ | |
| '''http://ensembl.org/biomart/martservice?query=''' \ | |
| '''<?xml version="1.0" encoding="UTF-8"?>''' \ | |
| '''<!DOCTYPE Query>''' \ | |
| '''<Query virtualSchemaName="default" formatter="CSV" header="0" uniqueRows="0" count="" datasetConfigVersion="0.6">''' \ |
This file contains hidden or 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
| // forward slashes don't work well in URI components even when encoded as %2F. Many server side implementations | |
| // still stumble on them. We can encode/decode the string with a simple scheme like: | |
| // 'hi / there / \\ dude / \\f\\b\\\\'.replace(/\\/g, '\\b').replace(/\//g, '\\f').replace(/\\f/g, '/').replace(/\\b/g, '\\'); | |
| function encURIComp(str) { | |
| return encodeURIComponent(str.replace(/\\/g, '\\b').replace(/\//g, '\\f')); | |
| } | |
| function decURIComp(str) { | |
| return decodeURIComponent(str).replace(/\\f/g, '/').replace(/\\b/g, '\\'); |
This file contains hidden or 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
| /** | |
| * This callback will be called with the file that was dropped. | |
| * @callback dropCallback | |
| * @param file the file object | |
| */ | |
| /** | |
| * Create a file drop area | |
| * @param activeElement | |
| * the element that the user can drop on to trigger a callback | |
| * @param highlightElement |
This file contains hidden or 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 -O | |
| import argparse | |
| import sys | |
| import numpy | |
| import h5py | |
| import csv | |
| class ColType: | |
| UNKNOWN = 1 |
This file contains hidden or 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
| // creating a priority queue with a lambda less operator | |
| auto pt_less = [&mat](const cv::Point& pt1, const cv::Point& pt2) -> bool { | |
| return mat.at<uint8_t>(pt1) < mat.at<uint8_t>(pt2); | |
| }; | |
| priority_queue<cv::Point, vector<cv::Point>, decltype(pt_less)> erosion_candidates(pt_less); |
This file contains hidden or 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
| /** | |
| * A little "class" to help out with tri state checkboxes. | |
| */ | |
| function TriStateCheckbox(checkbox) { | |
| var self = this; | |
| var checkedVal = checkbox.prop("checked"); | |
| var indeterminatePropName = "indeterminate"; | |
| /** |
This file contains hidden or 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
| import requests | |
| def main(): | |
| exampleTaxonomy = "mmusculus_gene_ensembl" | |
| exampleGene = "ENSMUSG00000086981" | |
| urlTemplate = \ | |
| '''http://ensembl.org/biomart/martservice?query=''' \ | |
| '''<?xml version="1.0" encoding="UTF-8"?>''' \ | |
| '''<!DOCTYPE Query>''' \ |
This file contains hidden or 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
| import requests | |
| import json | |
| # a helper function that returns the error message in case there is one and | |
| # None otherwise | |
| def get_err_msg(x): | |
| if 'errorMessage' in x: | |
| return x['errorMessage'] | |
| else: | |
| return None |
This file contains hidden or 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
| from cgi import parse_qs, escape | |
| def application(environ, start_response): | |
| parameters = parse_qs(environ.get('QUERY_STRING', '')) | |
| if 'subject' in parameters: | |
| subject = escape(parameters['subject'][0]) | |
| else: | |
| subject = 'World' | |
| start_response('200 OK', [('Content-Type', 'text/html')]) | |
| return ['Hello %(subject)s' % {'subject': subject}] |