We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

MultipleSeqAlignment object in biopython

hi

i have an aligmenet file which contains 3 species generated from clustalx

AAAACGT Alpha
AAA-CGT Beta
AAAAGGT Gamma

i already sliced the aligment using the predefined indexing in biopython align[:,:4]

but now when i print the result i get:

AAAA Alpha
AAA- Beta
AAAA Gamma

the questions is: how can i get only the sub-aligmenet as without the species names(like a multiple aligment object without species names) e.g something like that:

AAAA
AAA-
AAAA

i tried : align[:,:4].seq but it did not worked.

any help would be appreciated

thank you

2
Contributors
6
Replies
2 Days
Discussion Span
1 Year Ago
Last Updated
7
Views
weblover
Junior Poster
153 posts since Feb 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

from here http://biopython.org/DIST/docs/api/Bio.Align.MultipleSeqAlignment-class.html
looks like you should do just slice the part you want

print align[:,:1]

Can not test without any data even if one installs the biopython.

pyTony
pyMod
Moderator
6,299 posts since Apr 2010
Reputation Points: 879
Solved Threads: 984
Skill Endorsements: 26

thank you.

i already found this, but for example how can i take the columns between 4 and 10 without getting the specie names ???

weblover
Junior Poster
153 posts since Feb 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Doesn't the

print align[:,3:11]

work?

pyTony
pyMod
Moderator
6,299 posts since Apr 2010
Reputation Points: 879
Solved Threads: 984
Skill Endorsements: 26

Mmmm, no, it prints the needed columns but with the sepcies names ...

weblover
Junior Poster
153 posts since Feb 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

maybe you can line.split(None, 1)[0] to get rid of last word in each line, but there must be a proper way also.

data = """
AAAACGT Alpha
AAA-CGT Beta
AAAAGGT Gamma""".splitlines()

print('\n'.join(line.split(None, 1)[0] for line in data if ' ' in line))
pyTony
pyMod
Moderator
6,299 posts since Apr 2010
Reputation Points: 879
Solved Threads: 984
Skill Endorsements: 26

you cannot do this, because the result of align[:,3:11] contains something like that:

SingleLetterAlphabet() alignment with 3 rows and 7 columns
AAAACGT Alpha
AAA-CGT Beta
AAAAGGT Gamma

so the split will not work ..

weblover
Junior Poster
153 posts since Feb 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0911 seconds using 2.67MB