Commit 101a4bf9 authored by Laros's avatar Laros
Browse files

Added an optional output of good barcodes after testing.

parent 8741e506
...@@ -22,7 +22,7 @@ Licensed under the MIT license, see the LICENSE file. ...@@ -22,7 +22,7 @@ Licensed under the MIT license, see the LICENSE file.
RELEASE = False RELEASE = False
__version_info__ = ('0', '5', 'dev') __version_info__ = ('0', '5', '0')
__version__ = '.'.join(__version_info__) __version__ = '.'.join(__version_info__)
......
...@@ -173,7 +173,7 @@ def barcode(length, max_stretch, min_dist, distance): ...@@ -173,7 +173,7 @@ def barcode(length, max_stretch, min_dist, distance):
max_stretch), min_dist) max_stretch), min_dist)
#barcode #barcode
def testBarcodes(barcodes, min_dist, distance): def testBarcodes(barcodes, min_dist, distance, handle):
""" """
Test a set of barcodes. Test a set of barcodes.
...@@ -189,7 +189,11 @@ def testBarcodes(barcodes, min_dist, distance): ...@@ -189,7 +189,11 @@ def testBarcodes(barcodes, min_dist, distance):
""" """
B = BarCode(distance) B = BarCode(distance)
return len(barcodes) - len(B.filterDistance(barcodes, min_dist)) good_subset = B.filterDistance(barcodes, min_dist)
if handle:
handle.write("\n".join(good_subset))
return len(barcodes) - len(good_subset)
#testBarcodes #testBarcodes
def main(): def main():
...@@ -224,6 +228,8 @@ def main(): ...@@ -224,6 +228,8 @@ def main():
parser_test = subparsers.add_parser("test", parents=[input_parser, parser_test = subparsers.add_parser("test", parents=[input_parser,
distance_parser], description=docSplit(testBarcodes)) distance_parser], description=docSplit(testBarcodes))
parser_test.add_argument("-o", dest="output", type=argparse.FileType('w'),
help="list of good barcodes")
args = parser.parse_args() args = parser.parse_args()
...@@ -238,7 +244,7 @@ def main(): ...@@ -238,7 +244,7 @@ def main():
if args.subcommand == "test": if args.subcommand == "test":
print "%s barcodes violate the distance contraint." % testBarcodes( print "%s barcodes violate the distance contraint." % testBarcodes(
map(lambda x: x.strip(), args.INPUT.readlines()), args.distance, map(lambda x: x.strip(), args.INPUT.readlines()), args.distance,
dfunc) dfunc, args.output)
#main #main
if __name__ == "__main__": if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment