Question: (Closed) Computing The Reverse And Complement Of A Sequence With Pygr
0
gravatar for Biostar User
8.7 years ago by
Biostar User1.0k
Biostar User1.0k wrote:

Computing the reverse complement with the Pygr bioinformatics framework:

#
# Reverse complement example with pygr
#

from pygr.sequence import Sequence

# needs a separate function to reverse strings
def rev(it):
    "Reverses an interable and returns it as a string"
    return ''.join(reversed(it))

# original sequence as as string
seq = 'ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG'

# create a Sequence class  instance named bobo
dna = Sequence(seq,'bobo')

# sequence class' type and content
print type(dna)
print dna

# the -operator reverse complements the DNA, returns a new sequence
print -dna

# to reverse the DNA, reverse the input data
rdna = Sequence( rev(seq),'bobo')
print rdna

# to complement the DNA reverse complement, then reverse again
cseq = rev(str(-dna))
cdna = Sequence(cseq,'bobo')

print cdna

Produces the output:

<class 'pygr.sequence.Sequence'>
ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG
CTATCGGGCACCCTTTCAGCGGCCCATTACAATGGCCAT
GATAGCCCGTGGGAAAGTCGCCGGGTAATGTTACCGGTA
TACCGGTAACATTACCCGGCGACTTTCCCACGGGCTATC
python sequence • 2.5k views
ADD COMMENTlink modified 7.8 years ago by Lars Juhl Jensen11k • written 8.7 years ago by Biostar User1.0k

And what exactly is your question?

ADD REPLYlink written 8.7 years ago by Jeroen Van Goey2.2k

This post was not formulated in a question/answer format therefore will be closed.

ADD REPLYlink written 8.7 years ago by Istvan Albert ♦♦ 78k

This is not a question

ADD REPLYlink written 8.7 years ago by Fred Fleche4.2k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 962 users visited in the last hour