Package Bio :: Package Sequencing :: Package Applications :: Module _Novoalign
[hide private]
[frames] | no frames]

Source Code for Module Bio.Sequencing.Applications._Novoalign

  1  # Copyright 2009 by Osvaldo Zagordi.  All rights reserved. 
  2  # Revisions copyright 2010 by Peter Cock. 
  3  # This code is part of the Biopython distribution and governed by its 
  4  # license.  Please see the LICENSE file that should have been included 
  5  # as part of this package. 
  6  """Command line wrapper for the short read aligner Novoalign by Novocraft.""" 
  7   
  8  from __future__ import print_function 
  9   
 10  import types 
 11  from Bio.Application import _Option, AbstractCommandline 
 12   
 13   
14 -class NovoalignCommandline(AbstractCommandline):
15 """Command line wrapper for novoalign by Novocraft. 16 17 See www.novocraft.com - novoalign is a short read alignment program. 18 19 Example: 20 21 >>> from Bio.Sequencing.Applications import NovoalignCommandline 22 >>> novoalign_cline = NovoalignCommandline(database='some_db', 23 ... readfile='some_seq.txt') 24 >>> print(novoalign_cline) 25 novoalign -d some_db -f some_seq.txt 26 27 As with all the Biopython application wrappers, you can also add or 28 change options after creating the object: 29 30 >>> novoalign_cline.format = 'PRBnSEQ' 31 >>> novoalign_cline.r_method='0.99' # limited valid values 32 >>> novoalign_cline.fragment = '250 20' # must be given as a string 33 >>> novoalign_cline.miRNA = 100 34 >>> print(novoalign_cline) 35 novoalign -d some_db -f some_seq.txt -F PRBnSEQ -r 0.99 -i 250 20 -m 100 36 37 You would typically run the command line with novoalign_cline() or via 38 the Python subprocess module, as described in the Biopython tutorial. 39 40 Last checked against version: 2.05.04 41 """
42 - def __init__(self, cmd="novoalign", **kwargs):
43 44 READ_FORMAT = ['FA', 'SLXFQ', 'STDFQ', 'ILMFQ', 'PRB', 'PRBnSEQ'] 45 REPORT_FORMAT = ['Native', 'Pairwise', 'SAM'] 46 REPEAT_METHOD = ['None', 'Random', 'All', 'Exhaustive', '0.99'] 47 48 self.parameters = \ 49 [ 50 _Option(["-d", "database"], 51 "database filename", 52 filename=True, 53 equate=False), 54 _Option(["-f", "readfile"], 55 "read file", 56 filename=True, 57 equate=False), 58 _Option(["-F", "format"], 59 "Format of read files.\n\nAllowed values: %s" 60 % ", ".join(READ_FORMAT), 61 checker_function=lambda x: x in READ_FORMAT, 62 equate=False), 63 64 # Alignment scoring options 65 _Option(["-t", "threshold"], 66 "Threshold for alignment score", 67 checker_function=lambda x: isinstance(x, int), 68 equate=False), 69 _Option(["-g", "gap_open"], 70 "Gap opening penalty [default: 40]", 71 checker_function=lambda x: isinstance(x, int), 72 equate=False), 73 _Option(["-x", "gap_extend"], 74 "Gap extend penalty [default: 15]", 75 checker_function=lambda x: isinstance(x, int), 76 equate=False), 77 _Option(["-u", "unconverted"], 78 "Experimental: unconverted cytosines penalty in bisulfite mode\n\n" 79 "Default: no penalty", 80 checker_function=lambda x: isinstance(x, int), 81 equate=False), 82 83 # Quality control and read filtering 84 _Option(["-l", "good_bases"], 85 "Minimum number of good quality bases [default: log(N_g, 4) + 5]", 86 checker_function=lambda x: isinstance(x, int), 87 equate=False), 88 _Option(["-h", "homopolymer"], 89 "Homopolymer read filter [default: 20; disable: negative value]", 90 checker_function=lambda x: isinstance(x, int), 91 equate=False), 92 93 # Read preprocessing options 94 _Option(["-a", "adapter3"], 95 "Strips a 3' adapter sequence prior to alignment.\n\n" 96 "With paired ends two adapters can be specified", 97 checker_function=lambda x: isinstance(x, str), 98 equate=False), 99 _Option(["-n", "truncate"], 100 "Truncate to specific length before alignment", 101 checker_function=lambda x: isinstance(x, int), 102 equate=False), 103 _Option(["-s", "trimming"], 104 "If fail to align, trim by s bases until they map or become shorter than l.\n\n" 105 "Ddefault: 2", 106 checker_function=lambda x: isinstance(x, int), 107 equate=False), 108 _Option(["-5", "adapter5"], 109 "Strips a 5' adapter sequence.\n\n" 110 "Similar to -a (adaptor3), but on the 5' end.", 111 checker_function=lambda x: isinstance(x, str), 112 equate=False), 113 # Reporting options 114 _Option(["-o", "report"], 115 "Specifies the report format.\n\nAllowed values: %s\nDefault: Native" 116 % ", ".join(REPORT_FORMAT), 117 checker_function=lambda x: x in REPORT_FORMAT, 118 equate=False), 119 _Option(["-Q", "quality"], 120 "Lower threshold for an alignment to be reported [default: 0]", 121 checker_function=lambda x: isinstance(x, int), 122 equate=False), 123 _Option(["-R", "repeats"], 124 "If score difference is higher, report repeats.\n\n" 125 "Otherwise -r read method applies [default: 5]", 126 checker_function=lambda x: isinstance(x, int), 127 equate=False), 128 _Option(["-r", "r_method"], 129 "Methods to report reads with multiple matches.\n\n" 130 "Allowed values: %s\n" 131 "'All' and 'Exhaustive' accept limits." 132 % ", ".join(REPEAT_METHOD), 133 checker_function=lambda x: x.split()[0] in REPEAT_METHOD, 134 equate=False), 135 _Option(["-e", "recorded"], 136 "Alignments recorded with score equal to the best.\n\n" 137 "Default: 1000 in default read method, otherwise no limit.", 138 checker_function=lambda x: isinstance(x, int), 139 equate=False), 140 _Option(["-q", "qual_digits"], 141 "Decimal digits for quality scores [default: 0]", 142 checker_function=lambda x: isinstance(x, int), 143 equate=False), 144 145 # Paired end options 146 _Option(["-i", "fragment"], 147 "Fragment length (2 reads + insert) and standard deviation [default: 250 30]", 148 checker_function=lambda x: len(x.split()) == 2, 149 equate=False), 150 _Option(["-v", "variation"], 151 "Structural variation penalty [default: 70]", 152 checker_function=lambda x: isinstance(x, int), 153 equate=False), 154 155 # miRNA mode 156 _Option(["-m", "miRNA"], 157 "Sets miRNA mode and optionally sets a value for the region scanned [default: off]", 158 checker_function=lambda x: isinstance(x, int), 159 equate=False), 160 161 # Multithreading 162 _Option(["-c", "cores"], 163 "Number of threads, disabled on free versions [default: number of cores]", 164 checker_function=lambda x: isinstance(x, int), 165 equate=False), 166 167 # Quality calibrations 168 _Option(["-k", "read_cal"], 169 "Read quality calibration from file (mismatch counts)", 170 checker_function=lambda x: isinstance(x, str), 171 equate=False), 172 _Option(["-K", "write_cal"], 173 "Accumulate mismatch counts and write to file", 174 checker_function=lambda x: isinstance(x, str), 175 equate=False), 176 ] 177 AbstractCommandline.__init__(self, cmd, **kwargs)
178 179
180 -def _test():
181 """Run the module's doctests (PRIVATE).""" 182 print("Running Novoalign doctests...") 183 import doctest 184 doctest.testmod() 185 print("Done")
186 187 if __name__ == "__main__": 188 _test() 189