<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 GOparser Demo
Author
Step1:  Download all required data
Step2:  Extract list of human protein-coding genes
Step3:  Parse human GO annotations
Step4:  Get information about a specific GO term
Step5:  Find all GO terms that the MYC gene is annotated with
<ASSISTANT_TASK:>
Python Code:
# get package versions
from pkg_resources import require
print 'Package versions'
print '----------------'
print require('genometools')[0]
print require('goparser')[0]
gene_annotation_file = 'Homo_sapiens.GRCh38.82.gtf.gz'
protein_coding_gene_file = 'protein_coding_genes_human.tsv'
go_annotation_file = 'gene_association.goa_human.149.gz'
go_ontology_file = 'go-basic_2015-10-12.obo'
Explanation: GOparser Demo
Author: Florian Wagner
Email: florian.wagner@duke.edu
This notebook demonstrates how to use the GOparser package to parse and query Gene Ontology data.
End of explanation
# download gene annotations
!curl -o "$gene_annotation_file" \
        "ftp://ftp.ensembl.org/pub/release-82/gtf/homo_sapiens/Homo_sapiens.GRCh38.82.gtf.gz"
# download UniProt-GOA GO annotation file
!curl -o "$go_annotation_file" \
        "ftp://ftp.ebi.ac.uk/pub/databases/GO/goa/old/HUMAN/gene_association.goa_human.149.gz"
# look at which version of the Gene Ontology was used for the GO annotation file
# (answer: 2015-10-12)
!gunzip -c "$go_annotation_file" | head -n 12
# download gene ontology file
!curl -o "$go_ontology_file" \
        http://viewvc.geneontology.org/viewvc/GO-SVN/ontology-releases/2015-10-12/go-basic.obo?revision=29122
Explanation: Download all required data
End of explanation
# generate list of human protein-coding genes
species = 'human'
!gunzip -c $gene_annotation_file | \
        extract_protein_coding_genes.py -s $species -o $protein_coding_gene_file
Explanation: Extract list of human protein-coding genes
End of explanation
import sys
from genometools import misc
from goparser import GOParser
# configure a logger that prints to stdout
misc.configure_logger('goparser',log_stream=sys.stdout)
# instantiate a GOParser object
P = GOParser()
# parse the ontology (.obo) file from the Gene Ontology Consortium
P.parse_ontology(go_ontology_file)
# parse the GO annotation (.gaf) file from the UniProt-GOA database
# --- only include annotations with certain evidence codes
select_evidence = ['IDA','IGI','IMP','ISO','ISS','IC','NAS','TAS']
P.parse_annotations(go_annotation_file,protein_coding_gene_file,\
                    select_evidence=select_evidence)
Explanation: Parse human GO annotations
End of explanation
term = P.get_term_by_name('canonical Wnt signaling pathway')
print 'Term name:'
print '----------'
print term.get_pretty_format()
print
term_id = term.id
term_name = term.name
annotated_genes = P.get_goterm_genes(term_id)
print 'Genes annotated with GO term "%s", %s:' %(term_id,term_name)
print '------------------------------------------------------------------------'
print 'Total number of genes: %d' %(len(annotated_genes))
print ', '.join(sorted(annotated_genes))
Explanation: Get information about a specific GO term
End of explanation
associated_terms = P.get_gene_goterms('MYC')
print 'GO terms associated with MYC:'
print '-----------------------------'
print '\n'.join(sorted([t.get_pretty_format() for t in associated_terms]))
Explanation: Find all GO terms that the MYC gene is annotated with
End of explanation
<END_TASK>