0% found this document useful (0 votes)
41 views

Python

This document contains instructions and examples for exercises using Python to analyze DNA, RNA, and protein sequences. It includes definitions for a Myseq class to represent sequences and methods to analyze sequences like transcription, reverse complement, translation, and validation. It provides examples of creating ADN, ARN, and Proteina classes that inherit from Myseq and generating random DNA sequences with options to add, remove, or replace nucleotides.

Uploaded by

Zareth Huaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Python

This document contains instructions and examples for exercises using Python to analyze DNA, RNA, and protein sequences. It includes definitions for a Myseq class to represent sequences and methods to analyze sequences like transcription, reverse complement, translation, and validation. It provides examples of creating ADN, ARN, and Proteina classes that inherit from Myseq and generating random DNA sequences with options to add, remove, or replace nucleotides.

Uploaded by

Zareth Huaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

UNIVERSIDAD ANDINA DEL CUSCO

FACULTAD DE INGENIERÍA Y ARQUITECTURA


ESCUELA PROFESIONAL DE INGENIERÍA DE SISTEMAS

Ejercicios:

“PYTHON”

ASIGNATURA: Fundamentos de bioinformática

DOCENTE: ING. GONZALES CONDORI, HARRY YEISON

ESTUDIANTES:

Coronado Miranda, Jeffry

Palomino Yabarrena, Lyndon

Castro Cana, Christopher

Jurado Jalisto, Kelvin

CUSCO – PERÚ
2020

1
1.

2.

3.

2
4.

5.

6.

3
7.

8.

1. Print (secuencia, ("ATATATACG")

2. Print(complemento inverso,("ATCGCGAT")
3. Print(totalduplest ("ATATATATACG")

4. print("el tamaño de la primera proteina codificada es: " )


print(proteinacodificada("GAT"))

5. print(puedeser("GAT"))
6. print(counter("AUGATATATATA"))

7. Print (impresion("ttccgatcaatg","tjs"))

4
8. print(Busqueda("aagctaaatgctaatcgtacaagc",4))

Proy 1.
class Myseq:

def __len__(self):
return len(self.seq)

def __getitem__(self, n):


return self.seq[n]

def __getslice__(self, i, j):


return self.seq[i:j]

def __str__(self):
return self.seq

def sacarSecuenciaBiotipo(self):
return self.seq_type

def muestraInfoSecuencia(self):
print("Secuencia: "+self.seq+" biotype "+self.seq_type)

def alfabeto (self):


if(self.seq_type == "ADN"):
return "ACGT"
elif (self.seq_type == "ARN"):
return "ACGU"
elif(self.seq_type == "PROTEIN"):
return "ACDEFGHIKLMNPQRSTVWY"
else:
None

def validar(self):
alp = self.alfabeto()
res = True
i=0
while i < len(self.seq) and res:
if self.seq[i] not in alp:
res = False
else:
i+=1
return res

5
def transcripcion(self):
if(self.seq_type == "ADN"):
return Myseq(self.seq.replace("T","U"),"ARN")
else:
return None

def reverse_comp(self):
if(self.seq_type != "ADN"):
return None
comp = ""
for c in self.seq:
if(c == 'A'):
comp="T"+comp
elif(c == "T"):
comp="A"+comp
elif(c == "G"):
comp="C"+comp
elif(c == "C"):
comp="G"+comp

return Myseq(comp, "ADN")

def traducirCodon(cod,a):

tc = {"GCT":"A", "GCC":"A", "GCA":"A", "GCG":"A", "TGT":"C", "TGC":"C",


"GAT":"D", "GAC":"D", "GAA":"E", "GAG":"E", "TTT":"F", "TTC":"F",
"GGT":"G", "GGC":"G", "GGA":"G", "GGG":"G", "CAT":"H", "CAC":"H",
"ATA":"I", "ATT":"I", "ATC":"I", "AAA":"K","AAG":"K", "TTA":"L",
"TTG":"L", "CTT":"L","CTC":"L", "CTA":"L","CTG":"L", "ATG":"M",
"AAT":"N", "AAC":"N", "CCT":"P","CCC":"P", "CCA":"P","CCG":"P",
"CAA":"Q", "CAG":"Q", "CGT":"R","CGC":"R", "CGA":"R","CGG":"R",
"AGA":"R","AGG":"R", "TCT":"S","TCC":"S", "TCA":"S","TCG":"S",
"AGT":"S","AGC":"S", "ACT":"T","ACC":"T", "ACA":"T","ACG":"T",
"GTT":"V","GTC":"V", "GTA":"V","GTG":"V", "TGG":"W", "TAT":"Y",
"TAC":"Y", "TAA":"_", "TAG":"_", "TGA":"_"}

if a in tc:
return tc[a]

else:
return None

def traduccion(self,iniPos = 0):


if(self.seq_type != "ADN"):

6
return None
seq_aa=""
for pos in range(iniPos, len(self.seq)-2,3):
cod = self.seq[pos:pos+3]
a = str(self.translate_codon(cod))

seq_aa=seq_aa+a
return Myseq(seq_aa, "PROTEIN")

class ADN(Myseq):
def __init__ (self, seq, seq_type = "ADN"):
self.seq = seq.upper()
self.seq_type = seq_type

class ARN(Myseq):
def __init__ (self, seq, seq_type = "ARN"):
self.seq = seq.upper()
self.seq_type = seq_type

class Proteina(Myseq):
def __init__ (self, seq, seq_type = "PROTEIN"):
self.seq = seq.upper()
self.seq_type = seq_type

secuenciaA =
ADN("ATGTGATAAGAATAGAATGCTGAATAAATAGAATGACAT")
secuenciaB = ARN("MKVVLSVQERSVVSLL","PROTEIN")
print(secuenciaA.validar(),secuenciaB.validar())
print(secuenciaA)

7
Proy 2.
import random
def genADN():

DNA=['A','C','G','T']

tamaADN=len(DNA)
print(tamaADN)
for num in range(2):
ADN=random.choices(DNA,k=50)
print("Primer ADN: ",ADN)
mutati=input("Desea Ingresar mutaciones?: ")
if mutati=="1":
mutaciones =int(input("Ingrese la cantidad de mutaciones: "))
for i in range(mutaciones):
nucleotidos=input("Ingrese el nucleotido: ")
ADN.append(nucleotidos)
print("El nuevo ADN es:",ADN)
elif mutati=="0":
boolremo=input("Desea remover un compuesto?: ")
if boolremo=="1":
remover=int(input("Ingrese la cantidad a remover: "))
for i in range(remover):
nucleoremove=input("Ingrese el nucleotido: ")
ADN.remove(nucleoremove)
print("El nuevo ADN es:",ADN)
elif boolremo=="0":
replacesADN=input("Desea reemplazar algun compuesto: ")
if replacesADN=="1":
reemplace=int(input("Ingrese la cantidad a remover: "))
for i in range(reemplace):
valorre=input("Ingrese que compuesto reemplazar: ")
nucleoreplace=input("Ingrese el nucleotido: ")
for n,i in enumerate(ADN):

if i==valorre:
ADN[n]= nucleoreplace
else:
print("Valor no encontrado")
print("El nuevo ADN es:",ADN)
elif replacesADN=="0":

8
print("El ADN es: ",ADN)
print(genADN())

You might also like