Проблема с вызовом подпроцесса скрипта Python - PullRequest
1 голос
/ 06 ноября 2019

Ниже приведена ошибка, которую я получаю при запуске сценария growthpred-v1.07.py (соответствующие строки из этого сценария вставлены намного ниже)

Traceback (most recent call last):
  File "./growthpred-v1.07.py", line 396, in <module>
    main()      
  File "./growthpred-v1.07.py", line 354, in main
    nucfreqs=Getnucfreq(dirbin, dirinput, othfile)
  File "./growthpred-v1.07.py", line 173, in Getnucfreq
    nucfreqs = subprocess.Popen(["%swcountq" %(direx), "%s%s" %(dirfile,file)], stdout=subprocess.PIPE).communicate()[0]
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Соответствующие строки из сценария growthpred-v1.07.py:

def Getnucfreq(direx, dirfile, file):
        #calculates nucleotide frequency in quartets (neutral selection)
        nucfreqs = subprocess.Popen(["%swcountq" %(direx), "%s%s" %(dirfile,file)], stdout=subprocess.PIPE).communicate()[0]
        A = str.split(nucfreqs)[45]
        C = str.split(nucfreqs)[48]
        G = str.split(nucfreqs)[51]
        return (A,C,G)

def GetCUB(direx,A,C,G,code,dirfile,file,type,outfile):
        #calculates codon usage bias indexes ENCp and P (Vieira-Silva and Rocha, PlosGen)
        print "Calculate codon usage bias indexes for %s sequences" %(type)
        p1 = subprocess.Popen('%sutilCUB -A %s -C %s -G %s -c %s -t < %s%s' %(direx,A,C,G,code,dirfile,file), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
        f1 = open("%s%s.errors" %(dirfile,outfile),"a")
        f1.write(p1[1])
        f1.close()  
        f2 = open("%s%s.%s.enc.si" %(dirfile,outfile,type),"w")
        f2.write(p1[0])
        f2.close() 

def Getgentime_single(direx,dirshare,dirfile,outfile,OGT):
        #calculates minimum generation time (Vieira-Silva and Rocha, PlosGen)
        print "Calculate predicted minimum generation time"
        p1 = subprocess.Popen('%sR --slave -q --no-save < %sgetd_single.R %s%s.OTH.enc.si %s%s.HEG.enc.si %s %s%s.results' %(direx,dirshare,dirfile,outfile,dirfile,outfile,OGT,dirfile,outfile), shell=Tru$
        f1 = open("%s%s.errors" %(dirfile,outfile),"a")
        f1.write(p1[1])
        f1.close()  

def Getgentime_mixed(direx,dirshare,dirfile,outfile,OGT):
        #calculates minimum generation time (Vieira-Silva and Rocha, PlosGen)
        print "Calculate predicted minimum generation time"
        p1 = subprocess.Popen('%sR --slave -q --no-save < %sgetd_mixed.R %s%s.OTH.enc.si %s%s.HEG.enc.si %s %s%s.results' %(direx,dirshare,dirfile,outfile,dirfile,outfile,OGT,dirfile,outfile), shell=True$
f1 = open("%s%s.errors" %(dirfile,outfile),"a")
        f1.write(p1[1])
        f1.close()      

def Getogt(direx, dirfile, file, code, dirbin):
        #calculates optimal growth temperature (Zeldovich et al, PlosCompBiol, 2007)
        print "Calculate predicted optimal growth temperature"
        ogt = subprocess.Popen(["%sget_OGT.sh" %(direx), "%s" %(code), "%s%s" %(dirfile,file),"%s" %(dirbin)], stdout=subprocess.PIPE, stderr=None).communicate()[0]
        return ogt

def Getheg(direx, dirfile, file, hegdb,diroutfile,outfile,blastall,getentryF):
        #retrieves the set of seq from input file that have high similarity (Evalue<0.00001, identity>40%) and similar length (+-10%) to ribosomal database seqs 
        print "Blast against ribosomal protein database"
        subprocess.Popen('%sget_rprots.sh %s%s %s %s%s %s %s' %(direx,dirfile,file,hegdb,diroutfile,outfile,blastall,getentryF), shell=True, stdout=None, stderr=None).communicate()[0]

def Getcai(diremb,dirfile,fileheg,fileoth):
        #calculates codon adaptation index (Sharp and LI, NAR, 1987)
        subprocess.Popen('%scusp %s%s %s%s.cusp' %(diremb,dirfile,fileheg,dirfile,fileheg), shell=True, stdout=None, stderr=None).communicate()
        subprocess.Popen('%scai %s%s -cfile %s%s.cusp %s%s.cai' %(diremb,dirfile,fileoth,dirfile,fileheg,dirfile,fileoth), shell=True, stdout=None, stderr=None).communicate()
        subprocess.Popen('rm -f %s%s.cusp' %(dirfile,fileheg), shell=True, stdout=None, stderr=None).communicate()

def Join(dirfile,fileenc,filecai,outfile):
        #Creates CUB file by joining ENCp+P file with CAI file
        print "Create codon usage bias indexes file"
        p1=subprocess.Popen('cut -f 2,4 -d " " %s%s' %(dirfile,filecai), shell=True, stdout=subprocess.PIPE)
        p2=subprocess.Popen('sort', shell=True, stdout=subprocess.PIPE, stdin=p1.stdout).communicate()
        f1 = open("%s%s.2" %(dirfile,filecai),"w")
        f1.write(p2[0])
        f1.close()
p1=subprocess.Popen('sort %s%s' %(dirfile,fileenc), shell=True, stdout=subprocess.PIPE).communicate()
        f1 = open("%s%s.2" %(dirfile,fileenc),"w")
        f1.write(p1[0])
        f1.close()
        f1 = open("%s%s" %(dirfile,outfile),"a")
        f1.write("# NB: The Codon Adaptation Index is only an appropriate proxy \n# for the expression level of genes in fast growing cells \n# minimal doubling times under ~2h \n")
        f1.write("SeqID ENC ENCp P CAI \n")
        p1=subprocess.Popen('join %s%s %s%s' %(dirfile,fileenc+".2",dirfile,filecai+".2"), shell=True, stdout=subprocess.PIPE).communicate()
        f1.write(p1[0])  
        f1.close()
        subprocess.Popen('rm -f %s%s %s%s %s%s %s%s' %(dirfile,fileenc,dirfile,filecai,dirfile,fileenc+".2",dirfile,filecai+".2"), shell=True, stdout=None, stderr=None).communicate()[0]

def main():

Я был бы очень признателен за любые замечания по исправлению приведенного выше кода, чтобы избежать появления сообщения об ошибке, которое былоуказано в начале моего поста.

1 Ответ

0 голосов
/ 06 ноября 2019

Информация о ключе содержится в сообщении об ошибке:

OSError: [Errno 2] Нет такого файла или каталога

Это, вероятно, означает, что исполняемый файл wcountqне может быть найден в каталоге direx. Убедитесь, что исполняемый файл присутствует, и для программы указан правильный путь (direx).

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...