def generateGraph(self,fileName,graphType):
     consoleCommands.generateGraph(fileName,graphType,outputDirectory='/tmp')
     fileName2 = fileName.split('/')[-1]
     fileRoot = '.'.join(fileName2.split('.')[:-1])
     
     inputGraph = '/tmp/{1}_{0}.gml'.format(graphType,fileRoot)
     with open(os.devnull,'r') as f:
         result = call(['gml2gv',inputGraph],stdout=f)
     return result
示例#2
0
 def generateGraph(self,ticket,bnglContents,graphtype):
     print ticket
     pointer = tempfile.mkstemp(suffix='.bngl',text=True)
     with open(pointer[1],'w' ) as f:
         f.write(bnglContents)
     #try:
     if graphtype in ['regulatory','contactmap']:
         consoleCommands.setBngExecutable(bngDistro)
         consoleCommands.generateGraph(pointer[1],graphtype)
         name = pointer[1].split('.')[0]
         with open('{0}_{1}.gml'.format(name,graphtype),'r') as f:
             graphContent = f.read()         
             self.addToDict(ticket,graphContent)
             print 'success',ticket
     elif graphtype in ['sbgn_er']:
         consoleCommands.setBngExecutable(bngDistro)
         consoleCommands.generateGraph(pointer[1],'contactmap')
         name = pointer[1].split('.')[0]
         #with open('{0}_{1}.gml'.format(name,'contactmap'),'r') as f:
         #   graphContent = f.read()
         graphContent = networkx.read_gml('{0}_{1}.gml'.format(name,'contactmap'))
         sbgn = libsbgn.createSBNG_ER_gml(graphContent)
         self.addToDict(ticket,sbgn)
         print 'success',ticket