Skip to content

Commit

Permalink
Fix for standalone binary
Browse files Browse the repository at this point in the history
PyInstaller alters LD_LIBRARY_PATH which causes problems when calling external programs - clear this for these calls.
  • Loading branch information
davidemms committed Nov 8, 2016
1 parent bb048b4 commit ad0e83d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion 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.7"
version = "1.0.8"
requiredBlastVersion = "2.2.28+"

citation = """When publishing work that uses OrthoFinder please cite:
Expand Down
8 changes: 6 additions & 2 deletions orthofinder/orthofinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@
with open(os.devnull, "w") as f:
subprocess.call("taskset -p 0xffffffffffff %d" % os.getpid(), shell=True, stdout=f) # get round problem with python multiprocessing library that can set all cpu affinities to a single cpu


my_env = os.environ.copy()
if getattr(sys, 'frozen', False):
# my_env['LD_LIBRARY_PATH'] = my_env['LD_LIBRARY_PATH_ORIG']
my_env['LD_LIBRARY_PATH'] = ''

def RunBlastDBCommand(command):
capture = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
capture = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=my_env)
stdout = [x for x in capture.stdout]
stderr = [x for x in capture.stderr]
nLines_success= 10
Expand Down
8 changes: 6 additions & 2 deletions orthofinder/scripts/get_orthologues.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
import blast_file_processor as BlastFileProcessor

nThreads = util.nThreadsDefault
my_env = os.environ.copy()
if getattr(sys, 'frozen', False):
# my_env['LD_LIBRARY_PATH'] = my_env['LD_LIBRARY_PATH_ORIG']
my_env['LD_LIBRARY_PATH'] = ''

class Seq(object):
def __init__(self, seqInput):
Expand Down Expand Up @@ -208,7 +212,7 @@ def RunAstral(ogSet, treesPat, workingDir):
treesFN = dir_astral + "TreesFile.txt"
ConcatenateTrees(i_ogs_to_use, treesPat, treesFN)
speciesTreeFN = workingDir + "SpeciesTree_astral.txt"
subprocess.call(" ".join(["java", "-Xmx6000M", "-jar", "~/software/ASTRAL-multiind/Astral/astral.4.8.0.jar", "-a", tmFN, "-i", treesFN, "-o", speciesTreeFN]), shell=True)
subprocess.call(" ".join(["java", "-Xmx6000M", "-jar", "~/software/ASTRAL-multiind/Astral/astral.4.8.0.jar", "-a", tmFN, "-i", treesFN, "-o", speciesTreeFN]), shell=True, env=my_env)
return speciesTreeFN

# ==============================================================================================================================
Expand Down Expand Up @@ -455,7 +459,7 @@ def RunDlcpar(treesPat, ogSet, nOGs, speciesTreeFN, workingDir):

filenames = [dlcparResultsDir + os.path.split(treesPat % i)[1] for i in xrange(nOGs)]

dlcCommands = ['dlcpar_search -s %s -S %s -D 1 -C 0.125 %s -I .txt' % (speciesTreeFN, geneMapFN, fn) for fn in filenames]
dlcCommands = ['dlcpar_search -s %s -S %s -D 1 -C 0.125 %s -I .txt -x 1' % (speciesTreeFN, geneMapFN, fn) for fn in filenames]
# print(dlcCommands[0])
# use this to run in parallel
util.RunParallelOrderedCommandLists(nThreads, [[c] for c in dlcCommands], qHideStdout = True)
Expand Down
17 changes: 11 additions & 6 deletions orthofinder/scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@
FileInfo = namedtuple("FileInfo", "inputDir outputDir graphFilename")

picProtocol = 1
version = "1.0.7"
version = "1.0.8"

my_env = os.environ.copy()
if getattr(sys, 'frozen', False):
# my_env['LD_LIBRARY_PATH'] = my_env['LD_LIBRARY_PATH_ORIG']
my_env['LD_LIBRARY_PATH'] = ""

def PrintNoNewLine(text):
sys.stdout.write(text)
Expand All @@ -61,19 +66,19 @@ def PrintTime(message):
"""

def RunCommand(command):
subprocess.call(command)
subprocess.call(command, env=my_env)

def RunOrderedCommandList(commandSet, qHideStdout):
if qHideStdout:
for cmd in commandSet:
subprocess.call(cmd, shell=True, stdout=subprocess.PIPE)
subprocess.call(cmd, shell=True, stdout=subprocess.PIPE, env=my_env)
else:
for cmd in commandSet:
subprocess.call(cmd, shell=True)
subprocess.call(cmd, shell=True, env=my_env)

def CanRunCommand(command, qAllowStderr = False):
PrintNoNewLine("Test can run \"%s\"" % command) # print without newline
capture = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
capture = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=my_env)
stdout = [x for x in capture.stdout]
stderr = [x for x in capture.stderr]
if len(stdout) > 0 and (qAllowStderr or len(stderr) == 0):
Expand All @@ -90,7 +95,7 @@ def Worker_RunCommand(cmd_queue, nProcesses, nToDo):
nDone = i - nProcesses + 1
if nDone >= 0 and divmod(nDone, 10 if nToDo <= 200 else 100 if nToDo <= 2000 else 1000)[1] == 0:
PrintTime("Done %d of %d" % (nDone, nToDo))
subprocess.call(command)
subprocess.call(command, env=my_env)
except Queue.Empty:
return

Expand Down

0 comments on commit ad0e83d

Please sign in to comment.