Skip to content

Instantly share code, notes, and snippets.

View cbare's full-sized avatar
👹
¯\_(ツ)_/¯

Christopher Bare cbare

👹
¯\_(ツ)_/¯
View GitHub Profile
@cbare
cbare / feature_extraction_pipeline.py
Created August 27, 2015 18:02
An example of how to use Synapse Tables to store intermediate results in a feature extraction pipeline.
##==========================================================
## Tables Pipeline Example
##
## An example of using Synapse tables to store raw data and
## intermediate steps to extract features for downstream
## analysis
##==========================================================
import synapseclient
from synapseclient import Activity
from synapseclient import Entity, Project, Folder, File
@cbare
cbare / challenge-intro.template.md
Created February 5, 2014 17:27
Template for Synapse challenges

##Background Why is this an important question and why is it interesting for the participants?

##Registration

${{jointeam?teamId={team[id]}&showProfileForm=true&isMemberMessage=You have successfully joined the {name}}}

##Data description What data types and how many samples are provided. The Data Description page has more details.

@cbare
cbare / download_synapse_files.py
Created April 2, 2014 19:45
Demonstrate how to script file download from Synapse
import os
import synapseclient
syn = synapseclient.Synapse()
syn.login() # insert credentials here, unless you have a cached API key.
## ADChallenge_WorkingGroup (syn2343636) Files » ADNI » Genetics » GWAS
folder_id = 'syn2362101'
## Get all children of the parent folder
@cbare
cbare / grep_git_objects.py
Last active August 29, 2015 14:01
Find lost stuff in a git repository
############################################################
## Find lost stuff in a git repository ##
## ##
## run in the root of your git repo ##
## Usage: python grep_git_objects.py <target> ##
############################################################
import os
import sys
import subprocess
@cbare
cbare / wikipedia_revision_grabber.py
Created June 3, 2014 00:57
Retrieve the last 100 revisions of a wikipedia article
import synapseclient
from synapseclient import File, Project, Folder
syn = synapseclient.login()
## get latest 100 revisions of a wikipedia article
url = "http://en.wikipedia.org/w/api.php?action=query&titles=Crimea&prop=revisions&rvprop=ids|timestamp|flags|content&rvlimit=100&format=json"
response = requests.get(url)
crimea = response.json()
@cbare
cbare / runAttractorInCRCSC.py
Last active August 29, 2015 14:08
runAttractorInCRCSC: A sample analysis script for use in the [Mad Scientist Stu demo](https://www.synapse.org/#!Help:Collaboratorium)
###########################################################
##
## runAttractorInCRCSC
##
## A sample data analysis for use with the Mad Scientist
## Stu demo of Synapse:
## https://www.synapse.org/#!Help:Collaboratorium
###########################################################
"""
Perform Step 5 of the Mad Scientist Stu Synapse Tutorial.
@cbare
cbare / get_synthetic_challenge_4_submissions.py
Last active August 29, 2015 14:10
Read leaderboards and submission queue, build submission tarballs and metadata as .csv
################################################################
## get submissions and metadata for Synthetic challenge 4
################################################################
import synapseclient
from synapseclient import Activity
from synapseclient import Entity, Project, Folder, File
from synapseclient import Evaluation, Submission, SubmissionStatus
import os
import pandas as pd
@cbare
cbare / list_challenge_participants.py
Last active August 29, 2015 14:15
List Challenge Participants
import synapseclient
syn = synapseclient.Synapse()
syn.login()
# ID for challenge participants team
team_id = ??
results = list(syn._GET_paginated('/teamMembers/{id}'.format(id=team_id)))
print "Number of participants:", len(results)
@cbare
cbare / pilot-63_annotation_cleaning_code_scraps.py
Created February 14, 2015 00:23
Code scraps for cleaning annotations on pilot-63 VCF files.
from itertools import izip
import argparse
import os
import re
import sys
import synapseclient
import synapseclient.utils as utils
from synapseclient import Project, File, Folder, Activity
from synapseclient import Schema, Column, Table, Row, RowSet, as_table_columns
import pandas as pd
@cbare
cbare / add_participants_to_team.py
Created March 13, 2015 05:23
Example of how to add participants with pending join requests to a team
import synapseclient
from synapseclient.exceptions import SynapseError
team_id = "3325290"
approved_participant_ids = ["377358", "3321663"]
syn = synapseclient.Synapse()
## log in using cached API key.