Skip to content

Commit

Permalink
fix for EVM path issue and better logging for some modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Palmer authored and Jon Palmer committed Nov 25, 2016
1 parent a268d64 commit 5c58114
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bin/funannotate-functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def runIPRpython(Input):
Transcripts = os.path.join(outputdir, 'annotate_misc', 'genome.transcripts.fasta')
lib.gb2output(genbank, Proteins, Transcripts, Scaffolds)

#get absolute path for all input so there are no problems later
Scaffolds, Proteins, Transcripts, GFF = [os.path.abspath(i) for i in [Scaffolds, Proteins, Transcripts, GFF]] #suggestion via GitHub
#get absolute path for all input so there are no problems later, not using Transcripts yet could be error? so take out here
Scaffolds, Proteins, GFF = [os.path.abspath(i) for i in [Scaffolds, Proteins, GFF]] #suggestion via GitHub
'''
for i in Scaffolds, Proteins, Transcripts, GFF:
i = os.path.abspath(i)
Expand Down
11 changes: 7 additions & 4 deletions bin/funannotate-p2g.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ def tblastnFilter(input, query, cpus, output):
if not os.path.exists(output):
os.makedirs(output)
#start by formatting blast db/dustmasker filtered format
subprocess.call(['dustmasker', '-in', input, '-infmt', 'fasta', '-parse_seqids', '-outfmt', 'maskinfo_asn1_bin', '-out', 'genome_dust.asnb'], cwd = output, stdout = FNULL, stderr = FNULL)
subprocess.call(['makeblastdb', '-in', input, '-dbtype', 'nucl', '-parse_seqids', '-mask_data', 'genome_dust.asnb', '-out', 'genome'], cwd = output, stdout = FNULL, stderr = FNULL)
#okay, now run tblastn using uniprot proteins
subprocess.call(['tblastn', '-num_threads', str(cpus), '-db', 'genome', '-query', query, '-max_target_seqs', '1', '-db_soft_mask', '11', '-threshold', '999', '-max_intron_length', MaxIntron, '-evalue', '1e-10', '-outfmt', '6', '-out', 'filter.tblastn.tab'], cwd = output, stdout = FNULL, stderr = FNULL)
cmd = ['dustmasker', '-in', input, '-infmt', 'fasta', '-parse_seqids', '-outfmt', 'maskinfo_asn1_bin', '-out', 'genome_dust.asnb']
lib.runSubprocess(cmd, output, lib.log)
cmd = ['makeblastdb', '-in', input, '-dbtype', 'nucl', '-parse_seqids', '-mask_data', 'genome_dust.asnb', '-out', 'genome']
lib.runSubprocess(cmd, output, lib.log)
cmd = ['tblastn', '-num_threads', str(cpus), '-db', 'genome', '-query', query, '-max_target_seqs', '1', '-db_soft_mask', '11', '-threshold', '999', '-max_intron_length', MaxIntron, '-evalue', '1e-10', '-outfmt', '6', '-out', 'filter.tblastn.tab']
lib.runSubprocess(cmd, output, lib.log)

#now parse through results, generating a list for exonerate function
with open(os.path.join(output, 'filter.tblastn.tab')) as input:
reader = csv.reader(input, delimiter='\t')
Expand Down
4 changes: 4 additions & 0 deletions bin/funannotate-predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,14 @@ def __init__(self, prog):

#parse entire EVM command to script
if Exonerate and Transcripts:
Transcripts = os.path.abspath(Transcripts)
Exonerate = os.path.abspath(Exonerate)
evm_cmd = [sys.executable, EVM_script, os.path.join(args.out, 'logfiles', 'funannotate-EVM.log'), str(args.cpus), '--genome', MaskGenome, '--gene_predictions', Predictions, '--protein_alignments', Exonerate, '--transcript_alignments', Transcripts, '--weights', Weights, '--min_intron_length', str(args.min_intronlen), EVM_out]
elif not Exonerate and Transcripts:
Transcripts = os.path.abspath(Transcripts)
evm_cmd = [sys.executable, EVM_script, os.path.join(args.out, 'logfiles', 'funannotate-EVM.log'),str(args.cpus), '--genome', MaskGenome, '--gene_predictions', Predictions, '--transcript_alignments', Transcripts, '--weights', Weights, '--min_intron_length', str(args.min_intronlen), EVM_out]
elif not Transcripts and Exonerate:
Exonerate = os.path.abspath(Exonerate)
evm_cmd = [sys.executable, EVM_script, os.path.join(args.out, 'logfiles', 'funannotate-EVM.log'), str(args.cpus), '--genome', MaskGenome, '--gene_predictions', Predictions, '--protein_alignments', Exonerate, '--weights', Weights, '--min_intron_length', str(args.min_intronlen), EVM_out]
elif not any([Transcripts,Exonerate]):
evm_cmd = [sys.executable, EVM_script, os.path.join(args.out, 'logfiles', 'funannotate-EVM.log'), str(args.cpus), '--genome', MaskGenome, '--gene_predictions', Predictions, '--weights', Weights, '--min_intron_length', str(args.min_intronlen), EVM_out]
Expand Down
10 changes: 7 additions & 3 deletions bin/funannotate-runEVM.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def safe_run(*args, **kwargs):

#split partitions
lib.log.info("Setting up EVM partitions")
subprocess.call(cmd1, cwd = tmpdir, stdout = FNULL, stderr = FNULL)
lib.runSubprocess(cmd1, tmpdir, lib.log)
#subprocess.call(cmd1, cwd = tmpdir, stdout = FNULL, stderr = FNULL)
#check output
lib.checkinputs(os.path.join(tmpdir, 'partitions_list.out'))

Expand Down Expand Up @@ -118,11 +119,14 @@ def safe_run(*args, **kwargs):

#now combine the paritions
lib.log.info("Combining partitioned EVM outputs")
subprocess.call([perl, Combine, '--partitions', 'partitions_list.out', '--output_file_name', 'evm.out'], cwd = tmpdir, stdout = FNULL, stderr = FNULL)
partitioncmd = [perl, Combine, '--partitions', 'partitions_list.out', '--output_file_name', 'evm.out']
lib.runSubprocess(partitioncmd, tmpdir, lib.log)
#subprocess.call([perl, Combine, '--partitions', 'partitions_list.out', '--output_file_name', 'evm.out'], cwd = tmpdir, stdout = FNULL, stderr = FNULL)

#now convert to GFF3
lib.log.info("Converting EVM output to GFF3")
subprocess.call(cmd5, cwd = tmpdir, stdout = FNULL, stderr = FNULL)
lib.runSubprocess(cmd5, tmpdir, lib.log)
#subprocess.call(cmd5, cwd = tmpdir, stdout = FNULL, stderr = FNULL)

#now concatenate all GFF3 files together for a genome then
lib.log.info("Collecting all EVM results")
Expand Down
2 changes: 1 addition & 1 deletion funannotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def fmtcols(mylist, cols):
for i in range(0,num_lines))
return "\n".join(lines)

version = '0.3.11'
version = '0.3.12'

default_help = """
Usage: funannotate <command> <arguments>
Expand Down
11 changes: 10 additions & 1 deletion lib/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ class colr:
GRN = '\033[92m'
END = '\033[0m'
WARN = '\033[93m'


def runSubprocess(cmd, dir, logfile):
logfile.debug(' '.join(cmd))
proc = subprocess.Popen(cmd, cwd=dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
if stdout:
logfile.debug(stdout)
if stderr:
logfile.debug(stderr)

def hashfile(afile, hasher, blocksize=65536):
buf = afile.read(blocksize)
while len(buf) > 0:
Expand Down

0 comments on commit 5c58114

Please sign in to comment.