How to use the dnaio.Sequence function in dnaio

To help you get started, we’ve selected a few dnaio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marcelm / cutadapt / tests / test_utils.py View on Github external
def test_reverse_complemented_sequence():
    s = dnaio.Sequence("the_name", "ACGTTTGA", "B>%%BB5#")
    assert reverse_complemented_sequence(s) == dnaio.Sequence("the_name", "TCAAACGT", "#5BB%%>B")

    s = dnaio.Sequence("the_name", "ACGTTTGA")
    assert reverse_complemented_sequence(s) == dnaio.Sequence("the_name", "TCAAACGT")
github marcelm / cutadapt / tests / test_utils.py View on Github external
def test_reverse_complemented_sequence():
    s = dnaio.Sequence("the_name", "ACGTTTGA", "B>%%BB5#")
    assert reverse_complemented_sequence(s) == dnaio.Sequence("the_name", "TCAAACGT", "#5BB%%>B")

    s = dnaio.Sequence("the_name", "ACGTTTGA")
    assert reverse_complemented_sequence(s) == dnaio.Sequence("the_name", "TCAAACGT")
github marcelm / cutadapt / tests / test_modifiers.py View on Github external
def test_nend_trimmer():
    trimmer = NEndTrimmer()
    seqs = ['NNNNAAACCTTGGNNN', 'NNNNAAACNNNCTTGGNNN', 'NNNNNN']
    trims = ['AAACCTTGG', 'AAACNNNCTTGG', '']
    for seq, trimmed in zip(seqs, trims):
        _seq = Sequence('read1', seq, qualities='#'*len(seq))
        _trimmed = Sequence('read1', trimmed, qualities='#'*len(trimmed))
        assert trimmer(_seq, ModificationInfo(_seq)) == _trimmed
github marcelm / cutadapt / tests / test_qualtrim.py View on Github external
def test_nextseq_trim():
    s = Sequence('n', '', '')
    assert nextseq_trim_index(s, cutoff=22) == 0
    s = Sequence(
        'n',
        'TCTCGTATGCCGTCTTATGCTTGAAAAAAAAAAGGGGGGGGGGGGGGGGGNNNNNNNNNNNGGNGG',
        'AA//EAEE//A6///E//A//EA/EEEEEEAEA//EEEEEEEEEEEEEEE###########EE#EA'
    )
    assert nextseq_trim_index(s, cutoff=22) == 33
github marcelm / cutadapt / tests / test_adapters.py View on Github external
def test_linked_adapter():
    front_adapter = PrefixAdapter('AAAA', min_overlap=4)
    back_adapter = BackAdapter('TTTT', min_overlap=3)

    linked_adapter = LinkedAdapter(
        front_adapter, back_adapter, front_required=True, back_required=False, name='name')
    assert linked_adapter.front_adapter.min_overlap == 4
    assert linked_adapter.back_adapter.min_overlap == 3

    read = Sequence(name='seq', sequence='AAAACCCCCTTTT')
    trimmed = linked_adapter.match_to(read.sequence).trimmed(read)
    assert trimmed.name == 'seq'
    assert trimmed.sequence == 'CCCCC'
github marcelm / cutadapt / tests / test_trim.py View on Github external
def test_statistics():
    read = Sequence('name', 'AAAACCCCAAAA')
    adapters = [BackAdapter("CCCC", max_error_rate=0.1)]
    cutter = AdapterCutter(adapters, times=3)
    cutter(read, ModificationInfo(read))
    # TODO make this a lot simpler
    trimmed_bp = 0
    for adapter in adapters:
        for d in (cutter.adapter_statistics[adapter].front.lengths,
                cutter.adapter_statistics[adapter].back.lengths):
            trimmed_bp += sum(seqlen * count for (seqlen, count) in d.items())
    assert trimmed_bp <= len(read), trimmed_bp
github marcelm / cutadapt / tests / test_modifiers.py View on Github external
def test_shortener():
    read = Sequence('read1', 'ACGTTTACGTA', '##456789###')

    shortener = Shortener(0)
    assert shortener(read, ModificationInfo(read)) == Sequence('read1', '', '')

    shortener = Shortener(1)
    assert shortener(read, ModificationInfo(read)) == Sequence('read1', 'A', '#')

    shortener = Shortener(5)
    assert shortener(read, ModificationInfo(read)) == Sequence('read1', 'ACGTT', '##456')

    shortener = Shortener(100)
    assert shortener(read, ModificationInfo(read)) == read
github marcelm / cutadapt / tests / test_utils.py View on Github external
def test_reverse_complemented_sequence():
    s = dnaio.Sequence("the_name", "ACGTTTGA", "B>%%BB5#")
    assert reverse_complemented_sequence(s) == dnaio.Sequence("the_name", "TCAAACGT", "#5BB%%>B")

    s = dnaio.Sequence("the_name", "ACGTTTGA")
    assert reverse_complemented_sequence(s) == dnaio.Sequence("the_name", "TCAAACGT")
github marcelm / cutadapt / tests / test_parser.py View on Github external
def test_anywhere_parameter_front():
    parser = AdapterParser(max_error_rate=0.2, min_overlap=4, read_wildcards=False,
        adapter_wildcards=False, indels=True)
    adapter = list(parser.parse('CTGAAGTGAAGTACACGGTT;anywhere', 'front'))[0]
    assert isinstance(adapter, FrontAdapter)
    assert adapter._force_anywhere

    # TODO move the rest to a separate test
    read = Sequence('foo1', 'AAAAAAAAAACTGAAGTGAA')
    from cutadapt.modifiers import AdapterCutter
    cutter = AdapterCutter([adapter])
    trimmed_read = cutter(read, ModificationInfo(read))
    assert trimmed_read.sequence == ''
github marcelm / cutadapt / src / cutadapt / utils.py View on Github external
def reverse_complemented_sequence(sequence: dnaio.Sequence):
    if sequence.qualities is None:
        qualities = None
    else:
        qualities = sequence.qualities[::-1]
    return dnaio.Sequence(sequence.name, reverse_complement(sequence.sequence), qualities)

dnaio

Read and write FASTA and FASTQ files efficiently

MIT
Latest version published 12 days ago

Package Health Score

75 / 100
Full package analysis