From 3d56a6e4870058f78721fa733ae27f60ab4d0c21 Mon Sep 17 00:00:00 2001 From: David Emms <david_emms@hotmail.com> Date: Mon, 26 Sep 2016 11:39:20 +0100 Subject: [PATCH] Allow for shutil.rmtree errors. Resolves #30 --- Tests/test_orthofinder.py | 11 +++++------ orthofinder/orthofinder.py | 9 ++++----- orthofinder/scripts/get_orthologues.py | 10 +++++++--- orthofinder/scripts/util.py | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Tests/test_orthofinder.py b/Tests/test_orthofinder.py index 2be830c..4c7264e 100755 --- a/Tests/test_orthofinder.py +++ b/Tests/test_orthofinder.py @@ -34,7 +34,7 @@ exampleBlastDir = baseDir + "Input/SmallExampleDataset_ExampleBlastDir/" 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: @@ -50,10 +50,9 @@ expectedHelp="""OrthoFinder version %s Copyright (C) 2014 David Emms 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 -------------- @@ -91,14 +90,14 @@ Arguments 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. diff --git a/orthofinder/orthofinder.py b/orthofinder/orthofinder.py index d47d17f..7bbc206 100755 --- a/orthofinder/orthofinder.py +++ b/orthofinder/orthofinder.py @@ -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("--------------") @@ -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""") diff --git a/orthofinder/scripts/get_orthologues.py b/orthofinder/scripts/get_orthologues.py index 6902a83..e813f48 100755 --- a/orthofinder/scripts/get_orthologues.py +++ b/orthofinder/scripts/get_orthologues.py @@ -28,6 +28,7 @@ import os import sys import glob +import time import shutil import subprocess import numpy as np @@ -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: diff --git a/orthofinder/scripts/util.py b/orthofinder/scripts/util.py index 19018e2..ae592b1 100644 --- a/orthofinder/scripts/util.py +++ b/orthofinder/scripts/util.py @@ -47,7 +47,7 @@ SequencesInfo = namedtuple("SequencesInfo", "nSeqs nSpecies speciesToUse seqStar FileInfo = namedtuple("FileInfo", "inputDir outputDir graphFilename") picProtocol = 1 -version = "1.0.4" +version = "1.0.5" def PrintNoNewLine(text): sys.stdout.write(text) -- GitLab