Package Bio :: Package Align :: Package Applications :: Module _Probcons
[hide private]
[frames] | no frames]

Source Code for Module Bio.Align.Applications._Probcons

  1  # Copyright 2009 by Cymon J. Cox.  All rights reserved. 
  2  # This code is part of the Biopython distribution and governed by its 
  3  # license.  Please see the LICENSE file that should have been included 
  4  # as part of this package. 
  5  """Command line wrapper for the multiple alignment program PROBCONS. 
  6  """ 
  7   
  8  from __future__ import print_function 
  9   
 10  __docformat__ = "epytext en"  # Don't just use plain text in epydoc API pages! 
 11   
 12  from Bio.Application import _Option, _Switch, _Argument, AbstractCommandline 
 13   
 14   
15 -class ProbconsCommandline(AbstractCommandline):
16 """Command line wrapper for the multiple alignment program PROBCONS. 17 18 http://probcons.stanford.edu/ 19 20 Example: 21 22 To align a FASTA file (unaligned.fasta) with the output in ClustalW 23 format, and otherwise default settings, use: 24 25 >>> from Bio.Align.Applications import ProbconsCommandline 26 >>> probcons_cline = ProbconsCommandline(input="unaligned.fasta", 27 ... clustalw=True) 28 >>> print(probcons_cline) 29 probcons -clustalw unaligned.fasta 30 31 You would typically run the command line with probcons_cline() or via 32 the Python subprocess module, as described in the Biopython tutorial. 33 Note that PROBCONS will write the alignment to stdout, which you may 34 want to save to a file and then parse, e.g.:: 35 36 stdout, stderr = probcons_cline() 37 with open("aligned.aln", "w") as handle: 38 handle.write(stdout) 39 from Bio import AlignIO 40 align = AlignIO.read("aligned.fasta", "clustalw") 41 42 Alternatively, to parse the output with AlignIO directly you can 43 use StringIO to turn the string into a handle:: 44 45 stdout, stderr = probcons_cline() 46 from StringIO import StringIO 47 from Bio import AlignIO 48 align = AlignIO.read(StringIO(stdout), "clustalw") 49 50 Citations: 51 52 Do, C.B., Mahabhashyam, M.S.P., Brudno, M., and Batzoglou, S. 2005. 53 PROBCONS: Probabilistic Consistency-based Multiple Sequence Alignment. 54 Genome Research 15: 330-340. 55 56 Last checked against version: 1.12 57 """
58 - def __init__(self, cmd="probcons", **kwargs):
59 self.parameters = \ 60 [ 61 #Note that some options cannot be assigned via properties using the 62 #original documented option (because hyphens are not valid for names in 63 #python), e.g cmdline.pre-training = 3 will not work 64 #In these cases the shortened option name should be used 65 #cmdline.pre = 3 66 _Switch(["-clustalw", "clustalw"], 67 "Use CLUSTALW output format instead of MFA"), 68 _Option(["-c", "c", "--consistency", "consistency" ], 69 "Use 0 <= REPS <= 5 (default: 2) passes of consistency transformation", 70 checker_function=lambda x: x in range(0, 6), 71 equate=False), 72 _Option(["-ir", "--iterative-refinement", "iterative-refinement", "ir"], 73 "Use 0 <= REPS <= 1000 (default: 100) passes of " 74 "iterative-refinement", 75 checker_function=lambda x: x in range(0, 1001), 76 equate=False), 77 _Option(["-pre", "--pre-training", "pre-training", "pre"], 78 "Use 0 <= REPS <= 20 (default: 0) rounds of pretraining", 79 checker_function=lambda x: x in range(0, 21), 80 equate=False), 81 _Switch(["-pairs", "pairs"], 82 "Generate all-pairs pairwise alignments"), 83 _Switch(["-viterbi", "viterbi"], 84 "Use Viterbi algorithm to generate all pairs " 85 "(automatically enables -pairs)"), 86 _Switch(["-verbose", "verbose"], 87 "Report progress while aligning (default: off)"), 88 _Option(["-annot", "annot"], 89 "Write annotation for multiple alignment to FILENAME", 90 equate=False), 91 _Option(["-t", "t", "--train", "train"], 92 "Compute EM transition probabilities, store in FILENAME " 93 "(default: no training)", 94 equate=False), 95 _Switch(["-e", "e", "--emissions", "emissions"], 96 "Also reestimate emission probabilities (default: off)"), 97 _Option(["-p", "p", "--paramfile", "paramfile"], 98 "Read parameters from FILENAME", 99 equate=False), 100 _Switch(["-a", "--alignment-order", "alignment-order", "a"], 101 "Print sequences in alignment order rather than input " 102 "order (default: off)"), 103 #Input file name 104 _Argument(["input"], 105 "Input file name. Must be multiple FASTA alignment "+ 106 "(MFA) format", 107 filename=True, 108 is_required=True), 109 ] 110 AbstractCommandline.__init__(self, cmd, **kwargs)
111 112
113 -def _test():
114 """Run the module's doctests (PRIVATE).""" 115 print("Running modules doctests...") 116 import doctest 117 doctest.testmod() 118 print("Done")
119 120 if __name__ == "__main__": 121 _test() 122