Skip to content

Commit

Permalink
Allow for shutil.rmtree errors. Resolves #30
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemms committed Sep 26, 2016
1 parent 3a5fc36 commit 3d56a6e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
11 changes: 5 additions & 6 deletions Tests/test_orthofinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
goldResultsDir_smallExample = baseDir + "ExpectedOutput/SmallExampleDataset/"
goldPrepareBlastDir = baseDir + "ExpectedOutput/SmallExampleDataset_PreparedForBlast/"

version = "1.0.4"
version = "1.0.5"
requiredBlastVersion = "2.2.28+"

citation = """When publishing work that uses OrthoFinder please cite:
Expand All @@ -50,10 +50,9 @@
Simple Usage
------------
python orthofinder.py -f fasta_directory [-t number_of_blast_threads] [-a number_of_orthofinder_threads]
python orthofinder.py -f fasta_directory [-t number_of_blast_threads]
Infers orthogroups for the proteomes contained in fasta_directory running
number_of_blast_threads in parallel for the BLAST searches and subsequently running
number_of_orthofinder_threads in parallel for the OrthoFinder algorithm.
number_of_blast_threads in parallel for the BLAST searches and tree inference.
Advanced Usage
--------------
Expand Down Expand Up @@ -91,14 +90,14 @@
Running the OrthoFinder algorithm with a number of threads simultaneously increases the RAM
requirements proportionally so be aware of the amount of RAM you have available (and see README file).
Additionally, as the algorithm implementation is very fast, file reading is likely to be the
limiting factor above about 5-10 threads and additional threads may have little effect other than
limiting factor above about 5-10 threads and additional threads may have little effect other than to
increase RAM requirements. [Default is 1]
-g, --groups
Only infer orthogroups, do not infer gene trees of orthologues.
-I inflation_parameter, --inflation inflation_parameter
Specify a non-default inflation parameter for MCL. [Default is 1.5]
Specify a non-default inflation parameter for MCL. Not recommended. [Default is 1.5]
-x speciesInfoFilename, --orthoxml speciesInfoFilename
Output the orthogroups in the orthoxml format using the information in speciesInfoFilename.
Expand Down
9 changes: 4 additions & 5 deletions orthofinder/orthofinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,9 @@ def CanRunMCL():
def PrintHelp():
print("Simple Usage")
print("------------")
print("python orthofinder.py -f fasta_directory [-t number_of_blast_threads] [-a number_of_orthofinder_threads]")
print("python orthofinder.py -f fasta_directory [-t number_of_blast_threads]")
print(" Infers orthogroups for the proteomes contained in fasta_directory running")
print(" number_of_blast_threads in parallel for the BLAST searches and subsequently running")
print(" number_of_orthofinder_threads in parallel for the OrthoFinder algorithm.")
print(" number_of_blast_threads in parallel for the BLAST searches and tree inference.")
print("")
print("Advanced Usage")
print("--------------")
Expand Down Expand Up @@ -774,14 +773,14 @@ def PrintHelp():
Running the OrthoFinder algorithm with a number of threads simultaneously increases the RAM
requirements proportionally so be aware of the amount of RAM you have available (and see README file).
Additionally, as the algorithm implementation is very fast, file reading is likely to be the
limiting factor above about 5-10 threads and additional threads may have little effect other than
limiting factor above about 5-10 threads and additional threads may have little effect other than to
increase RAM requirements. [Default is %d]\n""" % util.nAlgDefault)

print("""-g, --groups
Only infer orthogroups, do not infer gene trees of orthologues.\n""")

print("""-I inflation_parameter, --inflation inflation_parameter
Specify a non-default inflation parameter for MCL. [Default is %0.1f]\n""" % mclInflation)
Specify a non-default inflation parameter for MCL. Not recommended. [Default is %0.1f]\n""" % mclInflation)

print("""-x speciesInfoFilename, --orthoxml speciesInfoFilename
Output the orthogroups in the orthoxml format using the information in speciesInfoFilename.\n""")
Expand Down
10 changes: 7 additions & 3 deletions orthofinder/scripts/get_orthologues.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import os
import sys
import glob
import time
import shutil
import subprocess
import numpy as np
Expand Down Expand Up @@ -524,15 +525,18 @@ def GetResultsFilesString(rootedSpeciesTreeFN):
st += "Species-by-species orthologues directory:\n %s\n\n" % resultsDir
return st


def CleanWorkingDir(dendroBlast):
dendroBlast.DeleteBlastMatrices()
dirs = ['Distances/', "matrices_orthologues/", "Trees_ids_arbitraryRoot/"]
for d in dirs:
dFull = dendroBlast.workingDir + d
if os.path.exists(dFull):
shutil.rmtree(dFull)

try:
shutil.rmtree(dFull)
except OSError:
time.sleep(1)
shutil.rmtree(dFull, True) # shutil / NFS bug - ignore errors, it's less crucial that the files are deleted

def GetOrthologues(orthofinderWorkingDir, orthofinderResultsDir, speciesToUse, nSpAll, clustersFilename_pairs, nProcesses):
ogSet = OrthoGroupsSet(orthofinderWorkingDir, speciesToUse, nSpAll, clustersFilename_pairs, idExtractor = util.FirstWordExtractor)
if len(ogSet.speciesToUse) < 4:
Expand Down
2 changes: 1 addition & 1 deletion orthofinder/scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
FileInfo = namedtuple("FileInfo", "inputDir outputDir graphFilename")

picProtocol = 1
version = "1.0.4"
version = "1.0.5"

def PrintNoNewLine(text):
sys.stdout.write(text)
Expand Down

0 comments on commit 3d56a6e

Please sign in to comment.