Exemple #1
0
import REVC;
import codons;
import string;
import re;

if __name__ == '__main__':
    pattern = r'(?=(M[^\.]*\.))'
    
    with open("rosalind_orf.txt") as spec:
        dna = spec.readline().strip()
        #dna = 'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG'
        print dna
        rna = string.replace(dna, 'T', 'U')
        result = {}
        trans = codons.proteinFromCodons(codons.splitCodons(rna))
        for p in [match.group(1)[:-1] for match in re.finditer(pattern, trans)]:
            result[p] = 1

        trans = codons.proteinFromCodons(codons.splitCodons(rna, 1))
        for p in [match.group(1)[:-1] for match in re.finditer(pattern, trans)]:
            result[p] = 1
        
        trans = codons.proteinFromCodons(codons.splitCodons(rna, 2))
        for p in [match.group(1)[:-1] for match in re.finditer(pattern, trans)]:
            result[p] = 1
        
        rna = string.replace(REVC.revc(dna), 'T', 'U')
        trans = codons.proteinFromCodons(codons.splitCodons(rna))
        for p in [match.group(1)[:-1] for match in re.finditer(pattern, trans)]:
            result[p] = 1
Exemple #2
0
'''
from itertools import chain
from codons import splitCodons
from codons import proteinFromCodons

with open("rosalind_splc.txt") as spec:
    seq = spec.readline().strip()
    exons = [exon.strip() for exon in spec]

print "Seq (len {0}):".format(len(seq)), seq
print exons

introns = [seq]
print introns
for ex in exons:
    sp = [intr.split(ex) for intr in introns]
    introns = list(chain.from_iterable((sp)))
    print introns

dna = "".join(introns)
print "DNA: ", dna

# Convert DNA to RNA
rna = dna.replace('T', 'U')
print "RNA: ", rna

codons = splitCodons(rna)
protein = proteinFromCodons(codons)

print
print protein[:-1]
Exemple #3
0
'''
from itertools import chain
from codons import splitCodons
from codons import proteinFromCodons

with open("rosalind_splc.txt") as spec:
    seq = spec.readline().strip()
    exons = [exon.strip() for exon in spec]
    
print "Seq (len {0}):".format(len(seq)), seq
print exons

introns = [ seq ]
print introns
for ex in exons:
    sp = [intr.split(ex) for intr in introns]
    introns = list(chain.from_iterable((sp)))
    print introns

dna = "".join(introns)
print "DNA: ", dna

# Convert DNA to RNA
rna = dna.replace('T', 'U')
print "RNA: ", rna

codons = splitCodons(rna)
protein = proteinFromCodons(codons)

print
print protein[:-1]
Exemple #4
0
import REVC
import codons
import string
import re

if __name__ == '__main__':
    pattern = r'(?=(M[^\.]*\.))'

    with open("rosalind_orf.txt") as spec:
        dna = spec.readline().strip()
        #dna = 'AGCCATGTAGCTAACTCAGGTTACATGGGGATGACCCCGCGACTTGGATTAGAGTCTCTTTTGGAATAAGCCTGAATGATCCGAGTAGCATCTCAG'
        print dna
        rna = string.replace(dna, 'T', 'U')
        result = {}
        trans = codons.proteinFromCodons(codons.splitCodons(rna))
        for p in [
                match.group(1)[:-1] for match in re.finditer(pattern, trans)
        ]:
            result[p] = 1

        trans = codons.proteinFromCodons(codons.splitCodons(rna, 1))
        for p in [
                match.group(1)[:-1] for match in re.finditer(pattern, trans)
        ]:
            result[p] = 1

        trans = codons.proteinFromCodons(codons.splitCodons(rna, 2))
        for p in [
                match.group(1)[:-1] for match in re.finditer(pattern, trans)
        ]: