Skip to content

Having issues specifying a usertree in phyml commandline. #2219

Closed

Description

@shivanishrm

I want to know what options of phyml does biopython allows to use. I'm not able to input a usertree. The error says option name u not available.

cmdline = PhymlCommandline(input=combo_phy, datatype='nt', bootstrap=3, u="C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk")
  File "C:\Program Files\Python\lib\site-packages\Bio\Phylo\Applications\_Phyml.py", line 256, in __init__
    AbstractCommandline.__init__(self, cmd, **kwargs)
  File "C:\Program Files\Python\lib\site-packages\Bio\Application\__init__.py", line 259, in __init__
    self.set_parameter(key, value)
  File "C:\Program Files\Python\lib\site-packages\Bio\Application\__init__.py", line 373, in set_parameter
    raise ValueError("Option name %s was not found." % name)
ValueError: Option name u was not found.

I'm writing a script that'd use phyml commandline by using a usertree to start with.

from Bio.Phylo import PhyloXML
from Bio.Phylo.Applications import PhymlCommandline
cmdline = PhymlCommandline(input=combo_phy, datatype='nt', bootstrap=3, u="C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk")
out_log, err_log = cmdline()

I am reporting a problem with Biopython1.74, Python 3.7.4, and windows 10 home operating
system .

Activity

  1. peterjc commented on Aug 20, 2019

    @peterjc
    Member

    You need to use input_tree =... rather than u=...

    >>> from Bio.Phylo.Applications import PhymlCommandline
    >>> help(PhymlCommandline())
    

    Curiously help(PhymlCommandline) or the online API documentation does not work as well, it has to be an instance of the object... there is likely something we can do better there.

  2. shivanishrm commented on Aug 20, 2019

    @shivanishrm
    Author

    Sir, I tried that as well.

    cmdline = PhymlCommandline(input=str1, datatype='nt', input_tree="C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk")
    out_log, err_log = cmdline()
    

    I got the following error:

    Traceback (most recent call last):
      File "C:\Users\Shivani\Documents\Research Internship\Files by Dates\August\19 August\gene_tree1.py", line 24, in <module>
        out_log, err_log = cmdline()
      File "C:\Program Files\Python\lib\site-packages\Bio\Application\__init__.py", line 527, in __call__
        stdout_str, stderr_str)
    Bio.Application.ApplicationError: Non-zero return code 1 from 'phyml -i gene2.phy -d nt -u "C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk"'
    [Finished in 2.962s]
    

    (Peter: Edited to add triple back-ticks before and after the code blocks, to display better here on GitHub)

  3. peterjc commented on Aug 20, 2019

    @peterjc
    Member

    Command line tools return an integer value (their "return code"), which by convention is zero for success, and non-zero for failure. In this case, return code 1 means a failure of some kind.

    The exact meaning of return codes will depend on the tool, in this case phyml.

    At this point I would work directly at the command line to see if I can produce the error, and if there are any clues in the output on screen (e.g. to stderr). What happens at the windows command prompt if you run this?

    phyml -i gene2.phy -d nt -u "C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk"
    

    You will need to make sure you are in the same directory as your input file gene2.phy - are you familiar with the concept of relative paths?

    As an aside, having spaces in filenames can make life much harder at the command line - if you can it is usually easier to avoid spaces in your directory and filenames.

  4. shivanishrm commented on Aug 21, 2019

    @shivanishrm
    Author

    Hi. I'm getting the results, when I type this command
    nt -u "C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk"

    I am familiar with relative paths so cd to the directory where gene2.phy was.

    Output look like this:

                                     ..........................
     ooooooooooooooooooooooooooooo        CURRENT SETTINGS        ooooooooooooooooooooooooooooooooooo
                                     ..........................
    
                    . Sequence filename:                             gene2.phy
                    . Data type:                                     dna
                    . Alphabet size:                                 4
                    . Sequence format:                               interleaved
                    . Number of data sets:                           1
                    . Nb of bootstrapped data sets:                  0
                    . Compute approximate likelihood ratio test:     yes (SH-like branch supports)
                    . Model name:                                    HKY85
                    . Ts/tv ratio:                                   estimated
                    . Proportion of invariable sites:                0.000000
                    . Number of subst. rate categs:                  4
                    . Gamma distribution parameter:                  estimated
                    . 'Middle' of each rate class:                   mean
                    . Nucleotide equilibrium frequencies:            empirical
                    . Optimise tree topology:                        yes
                    . Tree topology search:                          NNIs
                    . Starting tree:                                 user tree (usertree.nwk)
                    . Add random input tree:                         no
                    . Optimise branch lengths:                       yes
                    . Optimise substitution model parameters:        yes
                    . Run ID:                                        none
                    . Random seed:                                   1566369124
                    . Subtree patterns aliasing:                     no
                    . Version:                                       20120412
    
     oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
    
    
    
    . 33 patterns found (out of a total of 906 sites).
    
    . 884 sites without polymorphism (97.57%).
    
    . Reading tree...
    . Refining the input tree...
    
    . Maximizing likelihood (using NNI moves)...
    
    . (    0 sec) [     -1322.0312] [Ts/ts ratio        ][  1.788426]
    . (    0 sec) [     -1321.5969] [Alpha              ][  0.250961]
    . (    0 sec) [     -1321.5969] [Topology           ][# nnis=  0]
    . (    0 sec) [     -1321.5916] [Topology           ][# nnis=  0]
    . (    0 sec) [     -1321.5911] [Topology           ]
    . (    0 sec) [     -1321.5911] [Branch lengths     ]
    . (    1 sec) [     -1321.5910] [Ts/ts ratio        ][  1.790315]
    . (    1 sec) [     -1321.2935] [Alpha              ][  0.126111]
    . (    1 sec) [     -1321.2935] [Branch lengths     ]
    . (    1 sec) [     -1321.2928] [Ts/ts ratio        ][  1.794463]
    . (    1 sec) [     -1321.1831] [Alpha              ][  0.064398]
    . (    1 sec) [     -1321.1831] [Branch lengths     ]
    . (    1 sec) [     -1321.1830] [Ts/ts ratio        ][  1.796258]
    . (    1 sec) [     -1321.1700] [Alpha              ][  0.035968]
    . (    1 sec) [     -1321.1700] [Branch lengths     ]
    . (    1 sec) [     -1321.1700] [Ts/ts ratio        ][  1.796258]
    . (    1 sec) [     -1321.1696] [Alpha              ][  0.029099]
    . (    1 sec) [     -1321.1696] [Ts/ts ratio        ][  1.796258]
    . (    1 sec) [     -1321.1696] [Alpha              ][  0.029099]
    
    . Checking for NNIs, optimizing five branches...
    
    
    
    . Log likelihood of the current tree: -1321.169619.
    
    . Compute fast branch supports on the most likely tree...
    
    . Printing the most likely tree in file 'gene2.phy_phyml_tree.txt'...
    
    . Time used 0h0m2s
    
    oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
    
    C:\Users\Shivani\Documents\Research Internship\Files by Dates\August\19 Aug\Clustal Files>
    

    (Peter: Added triple back ticks for better display on GitHub)

  5. peterjc commented on Aug 21, 2019

    @peterjc
    Member

    I'm guessing that you mean you ran this command:

    phyml -i gene2.phy -d nt -u "C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk"
    

    not just:

    nt -u "C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk"
    

    Given it works at the command line, and assuming your working directory is the same, I would want to see the stdout/stderr from within Python:

    from Bio.Application import ApplicationError
    from Bio.Phylo import PhyloXML
    from Bio.Phylo.Applications import PhymlCommandline
    combo_phy = "gene2.phy"
    cmdline = PhymlCommandline(input=combo_phy, datatype='nt', bootstrap=3, input_tree ="C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk")
    try:
        out_log, err_log = cmdline()
    except ApplicationError as err:
        print("Return code:", err.returncode)
        print("Stderr:")
        print(err.stderr)
        print("Stdout:")
        print(err.stdout)

    Or, perhaps more simply:

    import os
    from Bio.Phylo import PhyloXML
    from Bio.Phylo.Applications import PhymlCommandline
    combo_phy = "gene2.phy"
    cmdline = PhymlCommandline(input=combo_phy, datatype='nt', bootstrap=3, input_tree ="C:/Users/Shivani/Documents/Research Internship/Files by Dates/August/19 Aug/usertree.nwk")
    os.system(str(cmdline))

    It looks like we don't have an example using ApplicationError in the tutorial right now... we should.

  6. shivanishrm commented on Aug 23, 2019

    @shivanishrm
    Author
  7. shivanishrm commented on Aug 23, 2019

    @shivanishrm
    Author
  8. peterjc commented on Aug 23, 2019

    @peterjc
    Member

    Every command line tool defines its own return codes - although often tools will just use 0 for success, and 1 for failure.

    In this case you should consult the phyml documentation. However, anything it prints to stdout/stderr is likely going to tell you what is wrong.

  9. shivanishrm commented on Aug 25, 2019

    @shivanishrm
    Author
  10. peterjc commented on Aug 25, 2019

    @peterjc
    Member

    Yes - and the meaning could be as simple as can’t find the input file. You said you checked the working directory but using absolute paths might help.

  11. peterjc commented on Nov 10, 2020

    @peterjc
    Member

    Closing as this appears to have been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions