Last active
February 9, 2016 20:07
-
-
Save necrolyte2/d8f62a337c9da9103fde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Bio.SeqRecord import SeqRecord | |
| from Bio.Seq import Seq | |
| from Bio.Alphabet import IUPAC | |
| """ | |
| record = SeqRecord( | |
| Seq("ATGC", IUPAC.ambiguous_dna), | |
| id="id1", | |
| name="id1name", | |
| description="some description" | |
| ) | |
| """ | |
| from hypothesis import strategies as st | |
| from hypothesis import find, note, given, assume | |
| make_seqrec = lambda seq, quals: \ | |
| SeqRecord(Seq(seq, IUPAC.ambiguous_dna), id='id', description='', letter_annotations={'phred_quality':quals}) | |
| rec = make_seqrec('AAAA', [40,40,40,40]) | |
| assert rec.format('fastq') == '@id\nAAAA\n+\nIIII\n', rec.format('fastq') | |
| recs = st.integers(min_value=10, max_value=50).flatmap( | |
| lambda n: | |
| st.builds( | |
| lambda seq, quals: | |
| SeqRecord(Seq(seq, IUPAC.ambiguous_dna), id='id', description='', letter_annotations={'phred_quality':quals}), | |
| st.text(alphabet='ATGC', min_size=n, max_size=n), | |
| st.lists(st.integers(min_value=0, max_value=40), min_size=n, max_size=n) | |
| ) | |
| ) | |
| print recs.example() | |
| @given(recs) | |
| def test_records_work(rec): | |
| #seq, qual = seqqual | |
| seq = rec.seq | |
| qual = rec.letter_annotations['phred_quality'] | |
| print 'Seq: %s\nQual: %s' % (seq, qual) | |
| assume(set(seq) != set('A')) | |
| assert False | |
| test_records_work() |
Author
necrolyte2
commented
Feb 9, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment