moshi4 / pyMSAviz

MSA(Multiple Sequence Alignment) visualization python package for sequence analysis
https://moshi4.github.io/pyMSAviz
MIT License
80 stars 14 forks source link

get specific positions from MSA #10

Closed Yogesh1-11 closed 8 months ago

Yogesh1-11 commented 8 months ago

hi what if i have to grep and display specific positions only lets say 30 40 50 and 60 from a MSA . is there a direct way rather than writing a new fasta file? also it will be great if you can add a functionality to upload newick format tree and showing phylogeny on left hand side of header

moshi4 commented 8 months ago

hi what if i have to grep and display specific positions only lets say 30 40 50 and 60 from a MSA . is there a direct way rather than writing a new fasta file?

You can easily achieve what you want to do by manipulating the MultipleSeqAlignment object in BioPython.

Code Example

from pymsaviz import MsaViz, get_msa_testdata

# Plot all msa result
msa_file = get_msa_testdata("HIGD2A.fa")
mv = MsaViz(msa_file, wrap_length=60)
mv.savefig("all_msa.png")

# Plot partial msa result [30,40,50,60]
part_msa = mv.msa[:, 29:30] + mv.msa[:, 39:40] + mv.msa[:, 49:50] + mv.msa[:, 59:60]
part_mv = MsaViz(part_msa)
part_mv.savefig("partial_msa.png")

all_msa.png

all_msa

partial_msa.png

partial_msa

also it will be great if you can add a functionality to upload newick format tree and showing phylogeny on left hand side of header

Due to technical difficulties, this feature will not be implemented.