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   
 11  from Bio.Application import _Option, _Switch, _Argument, AbstractCommandline 
 12   
 13   
14 -class ProbconsCommandline(AbstractCommandline):
15 """Command line wrapper for the multiple alignment program PROBCONS. 16 17 http://probcons.stanford.edu/ 18 19 Example: 20 -------- 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 53 Do, C.B., Mahabhashyam, M.S.P., Brudno, M., and Batzoglou, S. 2005. 54 PROBCONS: Probabilistic Consistency-based Multiple Sequence Alignment. 55 Genome Research 15: 330-340. 56 57 Last checked against version: 1.12 58 """
59 - def __init__(self, cmd="probcons", **kwargs):
60 self.parameters = \ 61 [ 62 # Note that some options cannot be assigned via properties using the 63 # original documented option (because hyphens are not valid for names in 64 # python), e.g cmdline.pre-training = 3 will not work 65 # In these cases the shortened option name should be used 66 # cmdline.pre = 3 67 _Switch(["-clustalw", "clustalw"], 68 "Use CLUSTALW output format instead of MFA"), 69 _Option(["-c", "c", "--consistency", "consistency"], 70 "Use 0 <= REPS <= 5 (default: 2) passes of consistency transformation", 71 checker_function=lambda x: x in range(0, 6), 72 equate=False), 73 _Option(["-ir", "--iterative-refinement", "iterative-refinement", "ir"], 74 "Use 0 <= REPS <= 1000 (default: 100) passes of " 75 "iterative-refinement", 76 checker_function=lambda x: x in range(0, 1001), 77 equate=False), 78 _Option(["-pre", "--pre-training", "pre-training", "pre"], 79 "Use 0 <= REPS <= 20 (default: 0) rounds of pretraining", 80 checker_function=lambda x: x in range(0, 21), 81 equate=False), 82 _Switch(["-pairs", "pairs"], 83 "Generate all-pairs pairwise alignments"), 84 _Switch(["-viterbi", "viterbi"], 85 "Use Viterbi algorithm to generate all pairs " 86 "(automatically enables -pairs)"), 87 _Switch(["-verbose", "verbose"], 88 "Report progress while aligning (default: off)"), 89 _Option(["-annot", "annot"], 90 "Write annotation for multiple alignment to FILENAME", 91 equate=False), 92 _Option(["-t", "t", "--train", "train"], 93 "Compute EM transition probabilities, store in FILENAME " 94 "(default: no training)", 95 equate=False), 96 _Switch(["-e", "e", "--emissions", "emissions"], 97 "Also reestimate emission probabilities (default: off)"), 98 _Option(["-p", "p", "--paramfile", "paramfile"], 99 "Read parameters from FILENAME", 100 equate=False), 101 _Switch(["-a", "--alignment-order", "alignment-order", "a"], 102 "Print sequences in alignment order rather than input " 103 "order (default: off)"), 104 # Input file name 105 _Argument(["input"], 106 "Input file name. Must be multiple FASTA alignment " 107 "(MFA) format", 108 filename=True, 109 is_required=True), 110 ] 111 AbstractCommandline.__init__(self, cmd, **kwargs)
112 113 114 if __name__ == "__main__": 115 from Bio._utils import run_doctest 116 run_doctest() 117