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

Edited 4 Years Ago by weblover

thank you.

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

Edited 4 Years Ago by weblover

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

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))

Edited 4 Years Ago by pyTony

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 ..

This article has been dead for over six months. Start a new discussion instead.