Hi Thomas, Still a little sketchy on the details due to you being on the move, so I'll just describe things in general terms and maybe that'll be enough.
Assuming you have a StructureSequence instance (i.e. something returned by mol.sequences() or mol.sequence(chainID)), then you can use the regexMatch and prositeMatch methods I mentioned earlier to get matching indices into the sequence. Those indices are into the full sequence (i.e. including gaps). StructureSequence has a residue attribute that corresponds 1-to-1 to the ungapped sequence. You can map the gapped indices return by the pattern matching to ungapped indices with the sequence's ungapped2gapped method. One needs to be aware the the "residue" at a sequence position can be None if there is missing structure in the model.
Anyway, here's some example code to color a particular sequence motif red:
# color 'ATYF' in chain A red
from chimera.colorTable import getColorByName
red = getColorByName("red")
chain = mol.sequence('A')
for match in chain.regexMatch("ATYF"):
u_start, u_end = [chain.gapped2ungapped(x) for x in match]
for res in chain.residues[u_start:u_end+1]:
if not res:
continue
res.ribbonColor = red
--Eric
Hi Eric ,
I have an algorithm that returns some subsequences of a structure and i want to color the corresponding structure segment automatically.
Thanks
Thomas
from the road
Hi Chimera Team,
How can I automate the Sequence View -> Edit -> Find Subsequence Tool programmatically with the Chimera shell or better within python?
I don't know what your context is here exactly, but if you have a Sequence object you can use its
regexMatch or prositeMatch methods to find subsequences. They return lists of (start, end) tuples. If you need more info, provide some more detail about your usage context and I can help better.
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
_______________________________________________
Chimera-dev mailing list
Chimera-dev@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev