Skip to content

Commit

Permalink
fixed issue with long path for signalp
Browse files Browse the repository at this point in the history
  • Loading branch information
trvinh committed Sep 5, 2024
1 parent 369eeef commit 570282f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 7 additions & 0 deletions greedyFAS/annoFAS/annoFAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ def main():
print('PID ' + str(os.getpid()))
runAnnoFas([seqFile, outPath, toolPath, force, outName, eFlps, signalpOrg, eFeature, eInstance, hmmCores, redo,
extract, annoFile, cpus, annoToolFile])
# remove tmp folders
if os.path.exists('tmp/signalp'):
subfolders = [ f.path for f in os.scandir('tmp') if f.is_dir() ]
if len(subfolders) == 1 and subfolders[0] == "tmp/signalp":
shutil.rmtree('tmp')
if os.path.exists(f'{outPath}/tmp'):
shutil.rmtree(f'{outPath}/tmp')
ende = time.time()
print('Finished in ' + '{:5.3f}s'.format(ende-start))

Expand Down
12 changes: 6 additions & 6 deletions greedyFAS/annoFAS/annoModules.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,15 @@ def doSignalp(args):
(seqFile, toolPath, org, outPath) = args
# create tmp folder for signalp output
seqFileName = seqFile.split('/')[-1].split('.')[0]
Path(outPath+'/tmp/signalp/'+seqFileName).mkdir(parents = True, exist_ok = True)
Path('/tmp/signalp/'+seqFileName).mkdir(parents = True, exist_ok = True)
# load fasta seq
inSeq = SeqIO.to_dict((SeqIO.parse(open(seqFile), 'fasta')))
# do signalp
cmd = '%s/SignalP/signalp -T %s/tmp/signalp/%s -t %s "%s"' % (toolPath, outPath, seqFileName, org, seqFile)
cmd = '%s/SignalP/signalp -T tmp/signalp/%s -t %s "%s"' % (toolPath, seqFileName, org, seqFile)
try:
signalpOut = subprocess.run([cmd], shell=True, capture_output=True, check=True)
except:
sys.exit('Error running\n%s' % cmd)
lines = signalpOut.stdout.decode().split('\n')
# print(signalpOut.stdout.decode())
# save to dict
annoOut = {}
if len(lines) > 0:
Expand Down Expand Up @@ -497,12 +495,14 @@ def doAnno(args):
subprocess.run([rmCmd], shell=True, check=True)
except:
sys.exit('Error running\n%s' % rmCmd)
if len(os.listdir(f'{outPath}/tmp/{pid}')) == 0:
shutil.rmtree(f'{outPath}/tmp')
if 'signalp' in toolList:
try:
seqFileName = seqFile.split('/')[-1].split('.')[0]
shutil.rmtree('%s/tmp/signalp/%s' % (outPath, seqFileName))
shutil.rmtree('tmp/signalp/%s' % seqFileName)
except:
sys.exit('Error deleting %s/tmp/signalp/%s_%s' % (outPath, outNameTmp, seqIdTmp))
sys.exit('Error deleting tmp/signalp/%s_%s' % (outNameTmp, seqIdTmp))
return final

# functions for posprocessing annotation dictionary
Expand Down
7 changes: 6 additions & 1 deletion greedyFAS/calcFAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from greedyFAS.mainFAS import fasInput, fasOutput, greedyFAS
from greedyFAS.mainFAS.fasInput import read_json
from pkg_resources import get_distribution
import shutil


def get_options():
Expand Down Expand Up @@ -344,7 +345,11 @@ def main():
annojobs.append(args.ref_2)
anno(annojobs, args, toolpath)
fas((args, toolpath))

# remove tmp folders
if os.path.exists('tmp/signalp'):
subfolders = [ f.path for f in os.scandir('tmp') if f.is_dir() ]
if len(subfolders) == 1 and subfolders[0] == "tmp/signalp":
shutil.rmtree('tmp')

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

setup(
name='greedyFAS',
version='1.18.12',
version='1.18.13',
python_requires='>=3.7.0',
description='A tool to compare protein feature architectures',
long_description=long_description,
Expand Down

0 comments on commit 570282f

Please sign in to comment.