def DoTrees(self, ogs, idDict, nProcesses, nSwitchToMafft=500):
     
     testFN = WriteTestFile(self.orthofinderWorkingDir)
     if not orthofinder.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 not orthofinder.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 not orthofinder.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
     os.remove(testFN)
     
     # 0
     dirs = ['Sequences', 'Alignments', 'Trees']
     for d in dirs:
         if not os.path.exists(self.baseOutputDir + d):
             os.mkdir(self.baseOutputDir + d)
     
     # 1.
     fastaWriter = FastaWriter(self.orthofinderWorkingDir)
     self.WriteFastaFiles(fastaWriter, ogs, idDict)
     print("\nFasta files for orthogroups have been written to:\n   %s" % self.baseOutputDir + "Sequences/")
     
     # 2
     IandOGs_toDo, nDone = self.OGsStillToDo(ogs)
     if nDone != 0: print("\nAlignments and trees have already been generated for %d orthogroups" % nDone)
     print("\nAlignments and trees will be generated for %d orthogroups" % len(IandOGs_toDo)) 
     
     # 3
     alignCommands = self.GetAlignmentCommands(IandOGs_toDo, nSwitchToMafft)
     alignmentFilesToUse = [self.GetAlignmentFilename(i) for i, og in IandOGs_toDo]
     treeCommands = self.GetTreeCommands(alignmentFilesToUse, IandOGs_toDo)
     commandsSet = [(alignCmd, treeCms) for alignCmd, treeCms in zip(alignCommands, treeCommands)]
         
     # 4
     if len(commandsSet) > 0:
         print("\nExample commands that will be run:")
         for cmdSet in commandsSet[:10]:
             for cmd in cmdSet:
                 print(cmd)
         print("")
         
     RunParallelCommandSets(nProcesses, commandsSet)
     
     orthofinder.PrintCitation()
     print("\nFasta files for orthogroups have been written to:\n   %s\n" % (self.baseOutputDir + "Sequences/"))
     print("Multiple sequences alignments have been written to:\n   %s\n" % (self.baseOutputDir + "Alignments/"))
     print("Gene trees have been written to:\n   %s\n" % (self.baseOutputDir + "Trees/"))
def PrintHelp():
    print("Usage")    
    print("-----")
    print("python trees_for_orthogroups.py orthofinder_results_directory [-t max_number_of_threads]")
    print("python trees_for_orthogroups.py -h")
    print("\n")
    
    print("Arguments")
    print("---------")
    print("""orthofinder_results_directory
    Generate multiple sequence alignments and trees for the orthogroups in orthofinder_results_directory.\n""")
    
    print("""-t max_number_of_threads, --threads max_number_of_threads
    The maximum number of processes to be run simultaneously. The deafult is %d but this 
    should be increased by the user to the maximum number of cores available.\n""" % orthofinder.nThreadsDefault)
        
    print("""-h, --help
   Print this help text""")
    orthofinder.PrintCitation()   
Example #3
0
def PrintHelp():
    print("Usage")
    print("-----")
    print(
        "get_orthologues.py orthofinder_results_directory [-t max_number_of_threads]"
    )
    print("get_orthologues.py -h")
    print("\n")

    print("Arguments")
    print("---------")
    print("""orthofinder_results_directory
    Generate gene trees for the orthogroups, generated rooted species tree and infer ortholgues.\n"""
          )

    print("""-t max_number_of_threads, --threads max_number_of_threads
    The maximum number of processes to be run simultaneously. The deafult is %d but this 
    should be increased by the user to the maximum number of cores available.\n"""
          % orthofinder.nThreadsDefault)

    print("""-h, --help
   Print this help text""")
    orthofinder.PrintCitation()
Example #4
0
        if arg == "-t" or arg == "--threads":
            if len(args) == 0:
                print("Missing option for command line argument -t")
                orthofinder.Fail()
            arg = args.pop(0)
            try:
                nProcesses = int(arg)
            except:
                print("Incorrect argument for number of threads: %s" % arg)
                orthofinder.Fail()
        else:
            userDir = arg

    # Check arguments
    print("0. Getting Orthologues")
    print("----------------------")
    if nProcesses == None:
        print(
            """\nNumber of parallel processes has not been specified, will use the default value.  
Number of parallel processes can be specified using the -t option.""")
        nProcesses = orthofinder.nThreadsDefault
    print("Using %d threads for alignments and trees" % nProcesses)

    orthofinderWorkingDir, orthofinderResultsDir, clustersFilename_pairs = tfo.GetOGsFile(
        userDir)
    resultsString = GetOrthologues(orthofinderWorkingDir,
                                   orthofinderResultsDir,
                                   clustersFilename_pairs, nProcesses)
    print(resultsString)
    orthofinder.PrintCitation()