Ejemplo n.º 1
0
def CanRunDependencies(workingDir):
    # FastME
    testFN = workingDir + "SimpleTest.phy"
    WriteTestDistancesFile(testFN)
    outFN = workingDir + "SimpleTest.tre"
    if os.path.exists(outFN): os.remove(outFN)
    if not util.CanRunCommand("fastme -i %s -o %s" % (testFN, outFN),
                              qAllowStderr=False):
        print("ERROR: Cannot run fastme")
        print(
            "Please check FastME is installed and that the executables are in the system path.\n"
        )
        return False
    os.remove(testFN)
    os.remove(outFN)
    fastme_stat_fn = workingDir + "SimpleTest.phy_fastme_stat.txt"
    if os.path.exists(fastme_stat_fn): os.remove(fastme_stat_fn)
    # DLCPar
    if not util.CanRunCommand("dlcpar_search --version", qAllowStderr=False):
        print("ERROR: Cannot run dlcpar_search")
        print(
            "Please check DLCpar is installed and that the executables are in the system path.\n"
        )
        return False
    return True
Ejemplo n.º 2
0
def CanRunOrthologueDependencies(workingDir, qMSAGeneTrees, qPhyldog,
                                 qStopAfterTrees, qInferSpeciesTree):
    # FastME
    if (not qMSAGeneTrees) or qInferSpeciesTree:
        testFN = workingDir + "SimpleTest.phy"
        WriteTestDistancesFile(testFN)
        outFN = workingDir + "SimpleTest.tre"
        if os.path.exists(outFN): os.remove(outFN)
        if not util.CanRunCommand("fastme -i %s -o %s" % (testFN, outFN),
                                  qAllowStderr=False):
            print("ERROR: Cannot run fastme")
            print(
                "Please check FastME is installed and that the executables are in the system path.\n"
            )
            return False
        os.remove(testFN)
        os.remove(outFN)
        fastme_stat_fn = workingDir + "SimpleTest.phy_fastme_stat.txt"
        if os.path.exists(fastme_stat_fn): os.remove(fastme_stat_fn)
    # DLCPar
    if not qStopAfterTrees:
        if not util.CanRunCommand("dlcpar_search --version",
                                  qAllowStderr=False):
            print("ERROR: Cannot run dlcpar_search")
            print(
                "Please check DLCpar is installed and that the executables are in the system path.\n"
            )
            return False

    # FastTree & MAFFT
    if qMSAGeneTrees or qPhyldog:
        testFN, temp_dir = msa.WriteTestFile(workingDir)
        if not util.CanRunCommand("mafft %s" % testFN, qAllowStderr=True):
            print("ERROR: Cannot run mafft")
            print(
                "Please check MAFFT is installed and that the executables are in the system path\n"
            )
            return False
        if qMSAGeneTrees and not util.CanRunCommand("FastTree %s" % testFN,
                                                    qAllowStderr=True):
            print("ERROR: Cannot run FastTree")
            print(
                "Please check FastTree is installed and that the executables are in the system path\n"
            )
            return False
        try:
            shutil.rmtree(temp_dir)
        except OSError:
            time.sleep(1)
            shutil.rmtree(
                temp_dir, True
            )  # shutil / NFS bug - ignore errors, it's less crucial that the files are deleted
    return True
Ejemplo n.º 3
0
def CanRunOrthologueDependencies(workingDir, qMSAGeneTrees, qPhyldog, qStopAfterTrees, msa_method, tree_method, tree_options, qInferSpeciesTree, qStopAfterAlignments):  
    # FastME
    if (not qMSAGeneTrees) or qInferSpeciesTree:
        testFN = workingDir + "SimpleTest.phy"
        WriteTestDistancesFile(testFN)
        outFN = workingDir + "SimpleTest.tre"
        if os.path.exists(outFN): os.remove(outFN)        
        if not util.CanRunCommand("fastme -i %s -o %s" % (testFN, outFN), qAllowStderr=False):
            print("ERROR: Cannot run fastme")
            print("Please check FastME is installed and that the executables are in the system path.\n")
            return False
        os.remove(testFN)
        os.remove(outFN)
        fastme_stat_fn = workingDir + "SimpleTest.phy_fastme_stat.txt"
        if os.path.exists(fastme_stat_fn): os.remove(fastme_stat_fn)
    # DLCPar
    if not (qStopAfterTrees or qStopAfterAlignments):
        if not util.CanRunCommand("dlcpar_search --version", qAllowStderr=False):
            print("ERROR: Cannot run dlcpar_search")
            print("Please check DLCpar is installed and that the executables are in the system path.\n")
            return False
    
    # FastTree & MAFFT
    if qMSAGeneTrees or qPhyldog:
        testFN, temp_dir = msa.WriteTestFile(workingDir)
        if msa_method == "mafft":
            if not util.CanRunCommand("mafft %s" % testFN, qAllowStderr=True):
                print("ERROR: Cannot run mafft")
                print("Please check MAFFT is installed and that the executables are in the system path\n")
                return False
        else:
            if not tree_options.TestMSAMethod(temp_dir, msa_method):
                print("ERROR: Cannot run user-configured MSA method '%s'" % msa_method)
                print("Please check program is installed and that it is correctly configured in the ~/.orthofinder.config file\n")
                return False
        if tree_method == "fasttree":
            if qMSAGeneTrees and (not qStopAfterAlignments) and not util.CanRunCommand("FastTree %s" % testFN, qAllowStderr=True):
                print("ERROR: Cannot run FastTree")
                print("Please check FastTree is installed and that the executables are in the system path\n")
                return False      
        else:
            if not tree_options.TestTreeMethod(temp_dir, tree_method):
                print("ERROR: Cannot run user-configured tree method '%s'" % tree_method)
                print("Please check program is installed and that it is correctly configured in the ~/.orthofinder.config file\n")
                return False
        try:
            shutil.rmtree(temp_dir)
        except OSError:
            time.sleep(1)
            shutil.rmtree(temp_dir, True)  # shutil / NFS bug - ignore errors, it's less crucial that the files are deleted
    return True    
Ejemplo n.º 4
0
def CanRunOrthologueDependencies(workingDir, qMSAGeneTrees, qPhyldog, qStopAfterTrees, msa_method, tree_method, recon_method, program_caller, qStopAfterAlignments):  
    # FastME
    if (not qMSAGeneTrees):
        testFN = workingDir + "SimpleTest.phy"
        WriteTestDistancesFile(testFN)
        outFN = workingDir + "SimpleTest.tre"
        if os.path.exists(outFN): os.remove(outFN)        
        if not util.CanRunCommand("fastme -i %s -o %s" % (testFN, outFN), qAllowStderr=False):
            print("ERROR: Cannot run fastme")
            print("Please check FastME is installed and that the executables are in the system path.\n")
            return False
        os.remove(testFN)
        os.remove(outFN)
        fastme_stat_fn = workingDir + "SimpleTest.phy_fastme_stat.txt"
        if os.path.exists(fastme_stat_fn): os.remove(fastme_stat_fn)
    # DLCPar
    if ("dlcpar" in recon_method) and not (qStopAfterTrees or qStopAfterAlignments):
        if not util.CanRunCommand("dlcpar_search --version", qAllowStderr=False):
            print("ERROR: Cannot run dlcpar_search")
            print("Please check DLCpar is installed and that the executables are in the system path.\n")
            return False
        if recon_method == "dlcpar_convergedsearch":
            capture = subprocess.Popen("dlcpar_search --version", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=my_env)
            stdout = "".join([x for x in capture.stdout])
            version = stdout.split()[-1]
            major, minor, release = map(int, version.split("."))
            # require 1.0.1 or above            
            actual = (major, minor, release)
            required = [1,0,1]
            versionOK = True
            for r, a in zip(required, actual):
                if a > r:
                    versionOK = True
                    break
                elif a < r:
                    versionOK = False
                    break
                else:
                    pass
                    # need to check next level down
            if not versionOK:
                print("ERROR: dlcpar_convergedsearch requires dlcpar_search version 1.0.1 or above")
                return False                   
    
    # FastTree & MAFFT
    if qMSAGeneTrees or qPhyldog:
        testFN, temp_dir = trees_msa.WriteTestFile(workingDir)
        if msa_method == "mafft":
            if not util.CanRunCommand("mafft %s" % testFN, qAllowStderr=True):
                print("ERROR: Cannot run mafft")
                print("Please check MAFFT is installed and that the executables are in the system path\n")
                return False
        elif msa_method != None:
            if not program_caller.TestMSAMethod(temp_dir, msa_method):
                print("ERROR: Cannot run user-configured MSA method '%s'" % msa_method)
                print("Please check program is installed and that it is correctly configured in the orthofinder/config.json file\n")
                return False
        if tree_method == "fasttree":
            if qMSAGeneTrees and (not qStopAfterAlignments) and not util.CanRunCommand("FastTree %s" % testFN, qAllowStderr=True):
                print("ERROR: Cannot run FastTree")
                print("Please check FastTree is installed and that the executables are in the system path\n")
                return False      
        elif tree_method != None:
            if not program_caller.TestTreeMethod(temp_dir, tree_method):
                print("ERROR: Cannot run user-configured tree method '%s'" % tree_method)
                print("Please check program is installed and that it is correctly configured in the orthofinder/config.json file\n")
                return False
        try:
            shutil.rmtree(temp_dir)
        except OSError:
            time.sleep(1)
            shutil.rmtree(temp_dir, True)  # shutil / NFS bug - ignore errors, it's less crucial that the files are deleted
            
    if qPhyldog:
        if not util.CanRunCommand("mpirun -np 1 phyldog", qAllowStderr=False):
            print("ERROR: Cannot run mpirun -np 1 phyldog")
            print("Please check phyldog is installed and that the executable is in the system path\n")
            return False
        
    return True