def loadMotifs(args,sigLvl,filterMotifs): """load and store motifs from XML files giving each a unique ID and culling out the ones we want.""" # --- load motifs --- motifDict = {} ID = 0 for path in args: tmpDict = parseScopeXML(path) # --- Give Each Motif its ID --- while tmpDict: k,v = tmpDict.popitem() # --- add the unique ID to the tuple key and the motif obj--- # -- key -- k = list(k) k.insert(2,ID) k = tuple(k) # -- obj -- v.motifID = ID # --- add motif to motifDict -- motifDict[k] = v ID+=1 # --- Cull Out The Ones We Want --- culledDict = {} while motifDict: k,v = motifDict.popitem() if float(v.sigvalue) < sigLvl: continue elif v.consensus in filterMotifs: culledDict[k] = v # --- Return Results --- for m in culledDict: print culledDict[m].consensus return culledDict
return False usage = '\n\npython %s outDir "geneName geneName ..." scopeOut.xml [scopeOut.xml]' % (sys.argv[0].split('/')[-1]) if len(sys.argv) < 3: print usage exit(0) # 1. Open all files into own scopeOut dicts inDict = {} for path in sys.argv[4:]: inDict[path] = parseScopeXML(path) # Parse GeneNames geneNames = sys.argv[2].split() # Print list of motifs and File names that hit genes listed: hits = {} for f in inDict: tmp = {} for motif in inDict[f]: if testForGenes(geneNames,motif): hits[(f,motif)] = inDict[f][motif] hitKeys = hits.keys() hitKeys.sort(key=lambda x: (x[0],x[1]))
#!/usr/bin/env python import optparse import sys from gusPyCode.defs.parseSCOPE import parseScopeXML,toXMSfile if __name__ == "__main__": #+++++++++++ Hard Code Figure Settings For Now +++++++++++ print '\n\n\n' #+++++++++++ File Parseing Etc +++++++++++ usage = """python %prog scopeOut.xml [scopeOut.xml ...]""" parser = optparse.OptionParser(usage) (opts, args) = parser.parse_args() if len(sys.argv) == 1: parser.print_help() exit(0) for xml in args: out = xml.replace('.xml','.xms') motifs = parseScopeXML(xml) toXMSfile(motifs,out)