#!/usr/bin/env python #Lorenz 8-3-09, # Quick script to run vienna findpath, # by running executable accessFindPath. # Inputs file formatted similar to fasta format, # with lines as in the file example.faa, as well # as the maxkeep parameter to the findPath algorithm. # # Displays to standard out barrier for each RNA and # sequence pair in the input file. # Outputs full paths to file ./fullPath.txt from subprocess import Popen, PIPE import sys, parseFaaForSeq if len(sys.argv)!=3: output= """Usage: %s filename maxkeep" filename has format > fasta comment sequence struc1 struc2 Displays to standard out barrier for each RNA and sequence pair in the input file. Outputs full paths to file ./fullPath.txt""" print output % sys.argv[0] exit(1) f=parseFaaForSeq.parseFaa(sys.argv[1]) maxkeep=int(sys.argv[2]) g=open("fullPath.txt", "w") (seq, comment, struc1, struc2)=f.nextSeq2Str() index=0 print "%20s %7s %s" %\ ("name", "maxkeep", "FindPath barrier") while (seq): max_list=[maxkeep] flag=False for maxkeep in max_list: p=Popen(["accessFindPath", seq, struc1, struc2, str(maxkeep)], stdin=PIPE, stdout=PIPE) # print '%s %s "%s" "%s" %d' % ("accessFindPath", seq, struc1, struc2, maxkeep) (pout, perr)=p.communicate(); g.write(comment+'\n'+seq+'\n'+pout) lines=pout.split('\n'); maxE=-9999. init=True for line in lines: if len(line)<2: continue if len(line)>4 and line[:4]=="time": time=float(line.split()[-1]) break E=float(line.split()[1]) if (init): initE=E init=False maxE=max(maxE,E) print "%20s %7d %14.2f" %\ (comment[:20], maxkeep, maxE-initE) index+=1 (seq, comment, struc1, struc2)=f.nextSeq2Str()