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
def is_prime(N): | |
for x in xrange(2, N): | |
if N % x == 0: | |
return False | |
return True | |
def sum_prime(N): | |
return sum(x for x in xrange(N) if is_prime(x)) |
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
import matplotlib | |
matplotlib.use("Agg") | |
import pyplot as plt | |
plt.plot([1, 2, 3]) | |
plt.savefig("something.png") |
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
_ref = "10.1371/journal.pone.0038772" | |
norm_vdw_volume = {'A': 1.00, 'M': 4.43, 'C': 2.43, 'N': 2.95, 'D': 2.78, 'P': 2.72, 'E': 3.78, 'Q': 3.95, 'F': 5.89, 'R': 6.13, | |
'G': 0.00, 'S': 1.60, 'H': 4.66, 'T': 2.60, 'I': 4.00, 'V': 3.00, 'K': 4.77, 'W': 8.08, 'L': 4.00, 'Y': 6.47} |
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
def remove_description_from_fasta(input, output, regex): | |
with open(input,) as input_stream, open(output , 'w') as output_stream: | |
for line in input_stream: | |
if line.startswith('>'): | |
if regex in line: | |
output_stream.write(line) | |
write = True | |
else: | |
write = False | |
elif write: |
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 | |
import requests | |
import sys | |
import utils | |
__author__ = 'tbrittoborges' | |
""" | |
Created on 14:45 04/11/2014 2014 | |
Given a list of UniProt accession id, return all missense variants. | |
All variants means: |
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
def get_url_or_retry(url, retry_in=(), wait=1, json=False, header={}, **params): | |
""" | |
Fetch an url using Requests or retry fetching it if the server is | |
complaining with retry_in error. | |
:param url: url to be fetched as a string | |
:param wait: sleeping between tries in seconds | |
:param params: request.get kwargs. | |
:return: url content or url content in json data structure. | |
""" | |
if json: |
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
import pandas as pd | |
colspecs = [(0, 6), (6, 11), (12, 16), (16, 17), (17, 20), (21, 22), (22, 26), | |
(26, 27), (30, 38), (38, 46), (46, 54), (54, 60), (60, 66), (76, 78), | |
(78, 80)] | |
names = ['ATOM', 'serial', 'name', 'altloc', 'resname', 'chainid', 'resseq', | |
'icode', 'x', 'y', 'z', 'occupancy', 'tempfactor', 'element', 'charge'] | |
pdb = pd.read_fwf(pdb_path, names=names, colspecs=colspecs) |
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
import requests | |
data = {"title": "Found a bug", # str | |
"body": "I'm having a problem with this.", # str | |
"assignee": None, # username str or None | |
"milestone": 1, # int | |
"labels": ['label1']} # list of str | |
def submit_github_issue(data, token, username, repo): | |
headers = {'Content-Type':'application/json', |
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
print '>\n' + '\n> \n'.join(list(df.query(...).sequence_column)) |
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
from urlparse import parse_qs | |
import pandas as pd | |
def _fetch_uniprot_gff(identifier): | |
""" | |
Retrieve UniProt data from the GFF file | |
:param identifier: UniProt accession identifier | |
:type identifier: str |
OlderNewer