コード例 #1
0
def test_fastareader():
	with seqio.FastaReader("tests/data/simple.fasta") as f:
		reads = list(f)
	assert reads == simple_fasta

	fasta = StringIO(">first_sequence\nSEQUENCE1\n>second_sequence\nSEQUENCE2\n")
	reads = list(seqio.FastaReader(fasta))
	assert reads == simple_fasta
コード例 #2
0
def test_wrong_fasta_format():
    fasta = StringIO(
        dedent("""
		# a comment
		# another one
		unexpected
		>first_sequence
		SEQUENCE1
		>second_sequence
		SEQUENCE2
		"""))
    reads = list(seqio.FastaReader(fasta))
コード例 #3
0
def test_fastareader_with_comments():
    fasta = StringIO(
        dedent("""
		# a comment
		# another one
		>first_sequence
		SEQUENCE1
		>second_sequence
		SEQUENCE2
		"""))
    reads = list(seqio.FastaReader(fasta))
    assert reads == simple_fasta
コード例 #4
0
def test_context_manager():
    filename = "tests/data/simple.fasta"
    with open(filename) as f:
        assert not f.closed
        reads = list(seqio.open(f))
        assert not f.closed
    assert f.closed

    with seqio.FastaReader(filename) as sr:
        tmp_sr = sr
        assert not sr.fp.closed
        reads = list(sr)
        assert not sr.fp.closed
    assert tmp_sr.fp.closed
コード例 #5
0
def test_fastareader_keeplinebreaks():
    with seqio.FastaReader("tests/data/simple.fasta",
                           keep_linebreaks=True) as f:
        reads = list(f)
    assert reads[0] == simple_fasta[0]
    assert reads[1].sequence == 'SEQUEN\nCE2'
コード例 #6
0
def test_fastareader():
    with seqio.FastaReader("tests/data/simple.fasta") as f:
        reads = list(f)
    assert reads == simple_fasta