Пример #1
0
def problem_revc():
    ''' http://rosalind.info/problems/revc/ '''
    from solutions.revc import revc
    f = readfile('rosalind_revc.txt')
    with f:
        for line in f:
            lineoutput(revc(line))
Пример #2
0
def orf(dna):
    ''' Open reading Frames

    Given: A DNA string s of length at most 1 kbp in FASTA format.

    Return: Every distinct candidate protein string that can be
    translated from ORFs of s. Strings can be returned in any order.
    >>> dna = ('AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAG'
    ...        'AGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG')
    >>> results = orf(dna)
    >>> for r in sorted(results):
    ...     print r
    M
    MGMTPRLGLESLLE
    MLLGSFRLIPKETLIQVAGSSPCNLS
    MTPRLGLESLLE
    '''
    rnadna = [rna(dna), rna(revc(dna))]

    frames, results = [], []
    for r in rnadna:
        frames.append(r)
        frames.append(r[1:])
        frames.append(r[2:])

    for frame in frames:
        protein = prot(frame, stop=False)
        for i in xrange(len(protein)):
            if protein[i] == 'M':
                e = protein[i:].find('$')
                results.append(protein[i:i+e])

    return [i for i in list(set(results)) if i != '']
Пример #3
0
def revp(dna):
    ''' Locating Restriction Sites

    Given: A DNA string of length at most 1 kbp in FASTA format.

    Return: The position and length of every reverse palindrome
    in the string having length between 4 and 12. You may return
    these pairs in any order.

    >>> dna = 'TCAATGCATGCGGGTCTATATGCAT'
    >>> results = revp(dna)
    >>> for r in sorted(list(results)):
    ...     print r
    (4, 6)
    (5, 4)
    (6, 6)
    (7, 4)
    (17, 4)
    (18, 4)
    (20, 6)
    (21, 4)
    '''
    for i in xrange(4, 12+1):
        for j in xrange(len(dna)-i+1):
            if dna[j:j+i] == revc(dna[j:j+i]):
                yield j+1, i