예제 #1
0
def get_consensus(aligned_r1, aligned_r2):
    consensus_seq = ctypes.create_string_buffer(aligned_r1.sequence)
    consensus_qual = ctypes.create_string_buffer(aligned_r1.qualities)

    for pos in range(len(aligned_r1)):
        if aligned_r2.qualities[pos] > consensus_qual[pos]:
            consensus_seq[pos] = aligned_r2.sequence[pos]
            consensus_qual[pos] = aligned_r2.qualities[pos]

    #Removes illumina's pair info from the consensus sequence name
    consensus_obj = seqio.Sequence(
        aligned_r1.name.split(" ")[0], consensus_seq.value,
        consensus_qual.value)

    return consensus_obj
예제 #2
0
def test_too_many_qualities():
    seqio.Sequence(name="name", sequence="ACGT", qualities="#####")
예제 #3
0
def align_sequences(r1, r2):
    new_r2 = seqio.Sequence(r2.name, rev_complement(r2.sequence),
                            r2.qualities[::-1])
    return r1, new_r2
예제 #4
0
# coding: utf-8
from __future__ import print_function, division, absolute_import

import sys
from textwrap import dedent
from nose.tools import raises
from cutadapt import seqio
from cutadapt.compat import StringIO

# files tests/data/simple.fast{q,a}
simple_fastq = [
    seqio.Sequence("first_sequence", "SEQUENCE1", ":6;;8<=:<"),
    seqio.Sequence("second_sequence", "SEQUENCE2", "83<??:(61")
]

simple_fasta = [seqio.Sequence(x.name, x.sequence, None) for x in simple_fastq]


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


def test_fastareader_with_comments():
    fasta = StringIO(