def print_sequences(args):
    db = sqlite3.connect(args.dbname)
    sql = fetch_reads
    if args.limit is not None:
        sql += ' LIMIT {}'.format(args.limit)
    for defline, blob in db.execute(sql).fetchall():
        x = FASTQ(blob)
        # x._def = "{}".format(rid)
        x._def = defline 
        x.unpack()
        print(x)
Example #2
0
# Compress the sequence, print the attributes again:

seq1.pack()
print_info(seq1)

# We should be able to restore the original attributes:

seq1.unpack()
print_info(seq1)

# Create another FASTQ object, this time from a byte array (e.g. a blob
# written into a database).  The sequence will have an empty defline, so
# we need to add one:

seq2 = FASTQ(b'\xc8P\x1e\x1e\xb4\xc8\xb9UU#')
seq2._def = 'restored sequence'
seq2.unpack()

print('\nTest Sequence 2:')
print(seq2)
print()

# This test shows how to read sequences from a file using the FASTQReader class.
# Since these are real sequences with actual deflines we can also demo the
# defline parser classes.

fn = 'test.fastq'
print('Sequences in file', fn)

with FASTQReader(fn) as file:
    for seq in file: