55import mappy as mp
66
77def main (argv ):
8- opts , args = getopt .getopt (argv [1 :], "x:n:m:k:w:r:c " )
8+ opts , args = getopt .getopt (argv [1 :], "x:n:m:k:w:r:cM " )
99 if len (args ) < 2 :
1010 print ("Usage: minimap2.py [options] <ref.fa>|<ref.mmi> <query.fq>" )
1111 print ("Options:" )
@@ -16,10 +16,11 @@ def main(argv):
1616 print (" -w INT minimizer window length" )
1717 print (" -r INT band width" )
1818 print (" -c output the cs tag" )
19+ print (" -M output the MD tag" )
1920 sys .exit (1 )
2021
2122 preset = min_cnt = min_sc = k = w = bw = None
22- out_cs = False
23+ out_cs = out_MD = False
2324 for opt , arg in opts :
2425 if opt == '-x' : preset = arg
2526 elif opt == '-n' : min_cnt = int (arg )
@@ -28,11 +29,12 @@ def main(argv):
2829 elif opt == '-k' : k = int (arg )
2930 elif opt == '-w' : w = int (arg )
3031 elif opt == '-c' : out_cs = True
32+ elif opt == '-M' : out_MD = True
3133
3234 a = mp .Aligner (args [0 ], preset = preset , min_cnt = min_cnt , min_chain_score = min_sc , k = k , w = w , bw = bw )
3335 if not a : raise Exception ("ERROR: failed to load/build index file '{}'" .format (args [0 ]))
3436 for name , seq , qual in mp .fastx_read (args [1 ]): # read one sequence
35- for h in a .map (seq , cs = out_cs ): # traverse hits
37+ for h in a .map (seq , cs = out_cs , MD = out_MD ): # traverse hits
3638 print ('{}\t {}\t {}' .format (name , len (seq ), h ))
3739
3840if __name__ == "__main__" :
0 commit comments