Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laros
barcode
Commits
101a4bf9
Commit
101a4bf9
authored
Aug 22, 2013
by
Laros
Browse files
Added an optional output of good barcodes after testing.
parent
8741e506
Changes
2
Hide whitespace changes
Inline
Side-by-side
barcode/__init__.py
View file @
101a4bf9
...
...
@@ -22,7 +22,7 @@ Licensed under the MIT license, see the LICENSE file.
RELEASE
=
False
__version_info__
=
(
'0'
,
'5'
,
'
dev
'
)
__version_info__
=
(
'0'
,
'5'
,
'
0
'
)
__version__
=
'.'
.
join
(
__version_info__
)
...
...
barcode/barcode.py
View file @
101a4bf9
...
...
@@ -173,7 +173,7 @@ def barcode(length, max_stretch, min_dist, distance):
max_stretch
),
min_dist
)
#barcode
def
testBarcodes
(
barcodes
,
min_dist
,
distance
):
def
testBarcodes
(
barcodes
,
min_dist
,
distance
,
handle
):
"""
Test a set of barcodes.
...
...
@@ -189,7 +189,11 @@ def testBarcodes(barcodes, min_dist, 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
def
main
():
...
...
@@ -224,6 +228,8 @@ def main():
parser_test
=
subparsers
.
add_parser
(
"test"
,
parents
=
[
input_parser
,
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
()
...
...
@@ -238,7 +244,7 @@ def main():
if
args
.
subcommand
==
"test"
:
print
"%s barcodes violate the distance contraint."
%
testBarcodes
(
map
(
lambda
x
:
x
.
strip
(),
args
.
INPUT
.
readlines
()),
args
.
distance
,
dfunc
)
dfunc
,
args
.
output
)
#main
if
__name__
==
"__main__"
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment