Entering edit mode
7.6 years ago
bio90029
▴
10
I have the above code to make a data base from different folder, and I am getting always the same error, 'contigs.fa' no recognized. I post my code, and hopefully someone can help me to find the error.
import glob, sys, os, subprocess
from Bio.Blast import NCBIXML
from Bio import SeqIO
def database_project():
#folders where my data are store
#looking for the files within the folder H*
files = glob.glob('/home/my_name/velvet_results2/H*')
for file in files:
#looking for contigs.fa in each folder
contigs=glob.glob(file + '/*.fa')
print contigs
#extract name of folder
temporary_db = os.path.basename(file)
output= '/home/mu_name/velvet_results2/' + temporary_db +'_db'
if os.path.exists(output):
print 'This folder already exist'
else:
os.makedirs(output)
cmd=['makeblastdb', '-in', 'contigs.fa', '-dbtype', 'nucl', '-out', 'temporary_db','-title', 'temporary_db']
my_file=subprocess.Popen(cmd)
my_file.wait()
#return database_id
print 'The database is done'
database_project()
Glad you figured it out, and learned something. I think your script can be condensed, and improved, but if it works, you're moving yourself forward with your skills.