Ejemplo n.º 1
0
    def PrepareScoaryCMDline(self):
        """
        Prepares arguments to correspond with argparse namespace and runs.
        Listens to sys.stdout and updates statusbar while scoary runs
        """
        citation=False
        RunScoary = True
        correction = []
        p_value_cutoff = []
        for m in self.Scoary_parameters["Cutoffs"]:
            if self.Scoary_parameters["Cutoffs"][m][0] == 1:
                correction.append(m)
                try:
                    p_value_cutoff.append(float(self.Scoary_parameters["Cutoffs"][m][1]))
                except ValueError:
                    print("Please enter real numbers in the p value fields")
                    RunScoary = False
                    break
                    
        delimiter = self.Scoary_parameters["Delimiter"]
        genes = self.Scoary_parameters["GPA"] if self.Scoary_parameters["GPA"] not in ["","Path to gene presence absence file"] else None
        try:
            max_hits = int(self.Scoary_parameters["Maxhits"]) if self.Scoary_parameters["Maxhits"] not in [""] else None
        except ValueError:
            print("Please enter a real number (or nothing) in the max hits field")
            max_hits = None
            RunScoary = False
        try:    
            permutations = abs(int(self.Scoary_parameters["Permutations"])) if self.Scoary_parameters["Permutations"] not in [""] else 0
        except ValueError:
            print("Please enter a real number (or nothing) in the max hits field")
            permutations = 0
            RunScoary = False
        newicktree = self.Scoary_parameters["Tree"] if self.Scoary_parameters["Tree"] not in ["", "(Optional) Path to custom tree file"] else None
        no_time = True if self.Scoary_parameters["Notime"] == 1 else False
        outdir = self.Scoary_parameters["Outdir"] if self.Scoary_parameters["Outdir"] not in ["","(Optional) Output directory"] else "./"
        restrict_to = self.Scoary_parameters["Restrict"] if self.Scoary_parameters["Restrict"] not in ["", "(Optional) Path to file naming isolates to include"] else None
        start_col = self.Scoary_parameters["Startcol"]
        test = False
        threads = 1
        traits = self.Scoary_parameters["Traits"] if self.Scoary_parameters["Traits"] not in ["","Path to traits/phenotype file"] else None
        upgma_tree = True if self.Scoary_parameters["Writetree"] == 1 else False
        write_reduced=False
        collapse=False
               
        myargs = argparse.Namespace(citation=citation, correction=correction, p_value_cutoff=p_value_cutoff, delimiter=delimiter, genes=genes, max_hits=max_hits, newicktree=newicktree,no_time=no_time,restrict_to=restrict_to,
        outdir=outdir,permute=permutations,start_col=start_col,test=test,threads=threads,traits=traits,upgma_tree=upgma_tree,write_reduced=write_reduced,collapse=collapse)
        
        if RunScoary:
            try:
                
                sm.main(args=myargs, cutoffs=dict(list(zip(correction, p_value_cutoff))),statusbar=sys.stdout)

            except SystemExit as SE:
                # Set status bar color to red?
                if str(SE) == "0":
                    print("Analysis complete!")
                else:
                    print("Fatal error: %s" % str(SE))
Ejemplo n.º 2
0
#!/usr/bin/env python

# Scoary - Microbial Pan-GWAS. Associates genes in Roary output with phenotypes
# Copyright (C) 2016  Ola Brynildsrud ([email protected])

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from scoary import methods

if __name__ == '__main__':
    print("Warning. Since 1.5.0 scoary.py is deprecated. "
          "Install Scoary using 'pip install scoary instead, and run using "
          "scoary <options>")
    methods.main()
Ejemplo n.º 3
0
#!/usr/bin/env python

# Scoary - Microbial Pan-GWAS. Associates genes in Roary output with phenotypes
# Copyright (C) 2016  Ola Brynildsrud ([email protected])

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from scoary import methods

if __name__ == '__main__':
    print("Warning. Since 1.5.0 scoary.py is deprecated. " \
    "Install Scoary using 'pip install git+https://github.com/AdmiralenOla/" \
    "Scoary.git' instead")
    methods.main()
Ejemplo n.º 4
0
    def PrepareScoaryCMDline(self):
        """
        Prepares arguments to correspond with argparse namespace and 
        runs. Listens to sys.stdout and updates statusbar.
        """
        citation = False
        RunScoary = True
        correction = []
        p_value_cutoff = []
        for m in self.Scoary_parameters["Cutoffs"]:
            if self.Scoary_parameters["Cutoffs"][m][0] == 1:
                correction.append(m)
                try:
                    p_value_cutoff.append(
                        float(self.Scoary_parameters["Cutoffs"][m][1]))
                except ValueError:
                    print("Please enter real numbers in the p value " "fields")
                    RunScoary = False
                    break

        delimiter = self.Scoary_parameters["Delimiter"]
        genes = (self.Scoary_parameters["GPA"] if self.Scoary_parameters["GPA"]
                 not in ["", "Path to gene presence absence file"] else None)
        try:
            max_hits = (int(self.Scoary_parameters["Maxhits"])
                        if self.Scoary_parameters["Maxhits"] not in [""] else
                        None)
        except ValueError:
            print("Please enter a real number (or nothing) in the max "
                  "hits field")
            max_hits = None
            RunScoary = False
        try:
            permutations = (abs(int(self.Scoary_parameters["Permutations"]))
                            if self.Scoary_parameters["Permutations"]
                            not in [""] else 0)
        except ValueError:
            print("Please enter a real number (or nothing) in the max "
                  "hits field")
            permutations = 0
            RunScoary = False
        newicktree = (
            self.Scoary_parameters["Tree"] if self.Scoary_parameters["Tree"]
            not in ["", "(Optional) Path to custom tree file"] else None)
        no_time = (True if self.Scoary_parameters["Notime"] == 1 else False)
        outdir = (self.Scoary_parameters["Outdir"]
                  if self.Scoary_parameters["Outdir"]
                  not in ["", "(Optional) Output directory"] else "./")
        restrict_to = (self.Scoary_parameters["Restrict"]
                       if self.Scoary_parameters["Restrict"] not in [
                           "", "(Optional) Path to file naming isolates to "
                           "include"
                       ] else None)
        start_col = self.Scoary_parameters["Startcol"]
        test = False
        threads = 1
        traits = (self.Scoary_parameters["Traits"]
                  if self.Scoary_parameters["Traits"]
                  not in ["", "Path to traits/phenotype file"] else None)
        upgma_tree = (True
                      if self.Scoary_parameters["Writetree"] == 1 else False)
        write_reduced = False
        collapse = (True if self.Scoary_parameters["Collapse"] == 1 else False)
        no_pairwise = (True if self.Scoary_parameters["No_pairwise"] == 1 else
                       False)

        myargs = argparse.Namespace(citation=citation,
                                    correction=correction,
                                    p_value_cutoff=p_value_cutoff,
                                    delimiter=delimiter,
                                    genes=genes,
                                    grabcols=[],
                                    max_hits=max_hits,
                                    newicktree=newicktree,
                                    no_time=no_time,
                                    restrict_to=restrict_to,
                                    outdir=outdir,
                                    permute=permutations,
                                    start_col=start_col,
                                    test=test,
                                    threads=threads,
                                    traits=traits,
                                    upgma_tree=upgma_tree,
                                    write_reduced=write_reduced,
                                    collapse=collapse,
                                    no_pairwise=no_pairwise)

        if RunScoary:
            try:

                sm.main(args=myargs,
                        cutoffs=dict(list(zip(correction, p_value_cutoff))),
                        statusbar=sys.stdout)

            except SystemExit as SE:
                # Set status bar color to red?
                if str(SE) == "0":
                    print("Analysis complete!")
                else:
                    print("Fatal error: %s" % str(SE))