Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
remove ternary, add test for one based flag
Browse files Browse the repository at this point in the history
  • Loading branch information
James Casbon committed May 31, 2011
1 parent 131db65 commit 5bc5127
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyfasta/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '-'):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5bc5127

Please sign in to comment.