Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove ternary, add test for one based flag

  • Loading branch information...
commit 5bc5127df387cb6b2ab289a603184c8ac5989b1d 1 parent 131db65
James Casbon authored
Showing with 5 additions and 1 deletion.
  1. +1 −1  pyfasta/fasta.py
  2. +4 −0 tests/test_all.py
View
2  pyfasta/fasta.py
@@ -185,7 +185,7 @@ def sequence(self, f, asstring=True, auto_rc=True
sequence = self._seq_from_keys(f, fasta, exon_keys)
if sequence is None:
- start = (f['start'] - 1) if one_based else f['start']
+ start = f['start'] - int(one_based)
sequence = fasta[start: f['stop']]
if auto_rc and f.get('strand') in (-1, '-1', '-'):
View
4 tests/test_all.py
@@ -40,6 +40,7 @@ def test_classes():
yield check_full_slice, f
yield check_array_copy, f
yield check_array, f
+ yield check_one_based, f
fasta_name = f.fasta_name
@@ -234,6 +235,9 @@ def check_array_copy(f):
assert a[1:5].tostring() == 'NNNN', a[1:5].tostring()
+def check_one_based(f):
+ assert f.sequence({'chr': 'chr1', 'start': 2, 'stop': 9}) == 'CTGACTGA'
+ assert f.sequence({'chr': 'chr1', 'start': 2, 'stop': 9}, one_based=False) == 'TGACTGA'
if __name__ == "__main__":
import nose

0 comments on commit 5bc5127

Please sign in to comment.
Something went wrong with that request. Please try again.