Beispiel #1
0
 def test_KEGG_download(self):
     """ Download a KEGG pathway from the KEGG server and write KGML.
     """
     # Download the KEGG ko01110 pathway, and render it
     pathway = retrieve_KEGG_pathway('ko01110')
     kgml_map = KGMLCanvas(pathway)
     kgml_map.import_imagemap = True
     kgml_map.draw(os.path.join('KEGG', 'ko01110.pdf'))
     # Download the KEGG ko01120 pathway and write to file as KGML
     retrieve_kgml_to_file("ko01120", os.path.join("KEGG", "ko01120.xml"))
Beispiel #2
0
 def test_KEGG_download(self):
     """ Download a KEGG pathway from the KEGG server and write KGML.
     """
     # Download the KEGG ko01110 pathway, and render it
     pathway = retrieve_KEGG_pathway('ko01110')
     kgml_map = KGMLCanvas(pathway)
     kgml_map.import_imagemap = True
     kgml_map.draw(os.path.join('KEGG', 'ko01110.pdf'))
     # Download the KEGG ko01120 pathway and write to file as KGML
     retrieve_kgml_to_file("ko01120", os.path.join("KEGG", "ko01120.xml"))
Beispiel #3
0
        koF.close()
    entryList = [e for e in keggPath.entries.values() if len(set(e.name.split()).intersection(koList))]
    return set(entryList)

def colorMapItems(geneSet, color, width):
    for e in geneSet:
	for g in e.graphics:
	    if g.type == 'line':
		g.fgcolor = color
		g.width = width
	    g.bgcolor = color

if not os.path.exists(args.outDir):
    os.makedirs(args.outDir)

pathway = retrieve_KEGG_pathway(args.path) #pathway of interest

#get KO numbers from previously created file
#ko = ['ko:'+ ko for (trans,sp,ko) in (line.strip().split("\t") for line in (open(args.KO, 'r')))]

knownKOSet = readKOFile(args.transKO, pathway)
enhanceSet = knownKOSet
if args.upKO != None:
    upKOSet = readKOFile(args.upKO, pathway)
    enhanceSet.update(upKOSet)
if args.downKO != None:
    downKOSet = readKOFile(args.downKO, pathway)
    enhanceSet.update(downKOSet)

notDE = set([e for e in pathway.orthologs if not len(set(e.name.split()).intersection(enhanceSet))])
############################
psr = argparse.ArgumentParser(description="Color KEGG maps with the Kegg Orthology entries that exist in your annotated transcriptome.")
# kegg pathway name
psr.add_argument('--path',help='Kegg Pathway Name', dest="path")
# folder for map output
psr.add_argument('--output',help='name of output folder', default = './', dest="outDir")
# KO (for just presence/absence)
psr.add_argument('--blastKO', help='Kegg Orthology from blast', dest='KO')
##############################
args = psr.parse_args()
##############################

if not os.path.exists(args.outDir):
    os.makedirs(args.outDir)

pathway = retrieve_KEGG_pathway(args.path) #pathway of interest
#pathway = read(args.path)
#import pdb;pdb.set_trace()

#get KO numbers from previously created file
ko = ['ko:'+ ko for (trans,sp,ko) in (line.strip().split("\t") for line in (open(args.KO, 'r')))]

#knownKOSet = set([e for e in pathway.entries.values() if len(set(e.name.split()).intersection(ko))])
knownKOSet = set([e for e in pathway.orthologs if len(set(e.name.split()).intersection(ko))])

def colorMapItems(geneSet, color, width):
    for e in geneSet:
	for g in e.graphics:
	    if g.type == 'line':
		g.fgcolor = color
		g.width = width
Beispiel #5
0
import sys
import os
import urllib2
from KGML_scrape import retrieve_kgml_to_file, retrieve_KEGG_pathway
from KGML_vis import KGMLCanvas

goal_dir = os.path.dirname(os.path.abspath(__file__)) + "\..\Downloads"
pathway = retrieve_KEGG_pathway(sys.argv[1])
kgml_map = KGMLCanvas(pathway)
kgml_map.import_imagemap = True
kgml_map.draw(
    os.path.join(os.path.normpath(goal_dir) + '\PDF', sys.argv[1] + '.pdf'))
retrieve_kgml_to_file(
    sys.argv[1],
    os.path.join(os.path.normpath(goal_dir) + '\XML', sys.argv[1] + '.xml'))
print sys.argv[1] + '.pdf'