Are you making a biology program Srinivas?

----- Original Message -----
From: "Kent Johnson" <[EMAIL PROTECTED]>
Cc: <tutor@python.org>
Sent: Sunday, July 31, 2005 2:46 PM
Subject: Re: [Tutor] substitute function


> Srinivas Iyyer wrote:
> > Hello group:
> >
> > Is there a 'substitute' function in python.
> >
> > For example:
> > I want to substitute A with T and G with C and vice
> > versa
> >
> > A -> T
> > G -> C
> > T -> A
> > c -> G
>
> You can do this with the translate() method of a string. It is a two-step
process. First you have to make a translation table that defines the
translation. Do this with string.maketrans():
>  >>> import string
>  >>> xlate = string.maketrans('AGTC', 'TCAG')
>
> Next use the translation table to translate the string of interest:
>  >>> 'AAGTTC'.translate(xlate)
> 'TTCAAG'
>
> Kent
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to