Last active
August 8, 2018 13:36
-
-
Save neksa/c7570eab505dd2b7c2f74646aa549f90 to your computer and use it in GitHub Desktop.
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 | |
import json | |
# MUTAGENE_URL = "https://www.ncbi.nlm.nih.gov/research/mutagene" | |
# MUTAGENE_URL = "https://dev.ncbi.nlm.nih.gov/research/mutagene" | |
MUTAGENE_URL = "https://mwebdev2/research/mutagene" | |
# MUTAGENE_URL = "http://localhost:5000" | |
def get_motifs(fname, assembly=37): | |
""" | |
Identify mutational motifs in a VCF or MAF sample | |
""" | |
url = MUTAGENE_URL + '/pub/api/identify/motifs' | |
files = {'file': open(fname, 'rb')} | |
r = requests.post(url, files=files, data={'assembly': assembly}) | |
if r.status_code == 200: | |
return r.json()['motifs'] | |
def print_motifs(motifs): | |
""" | |
Printing the results of motif identification | |
""" | |
if motifs is None: | |
print("Empty") | |
return | |
for m in motifs: | |
print("{}\t{}\t{:.2f}\t{:.2e}\t{}".format( | |
m['name'], m['motif'], | |
m['enrichment'], m['pvalue'], | |
m['mutations'])) | |
print() | |
if __name__ == '__main__': | |
vcf_files = ['test.vcf', ] | |
for file_name in vcf_files: | |
motifs = get_motifs(file_name, assembly=37) | |
print_motifs(motifs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment