[chimera-dev] [Chimera-users] Find subsequence programatically

Eric Pettersen pett at cgl.ucsf.edu
Thu Jan 22 17:27:44 PST 2015


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

On Jan 22, 2015, at 4:56 PM, Thomas Hrabe <thrabe at sanfordburnham.org> wrote:

> 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
> 
> Am 22.01.2015 um 16:37 schrieb Eric Pettersen <pett at cgl.ucsf.edu>:
> 
>> On Jan 22, 2015, at 4:21 PM, Thomas Hrabe <thrabe at sanfordburnham.org> wrote:
>> 
>>> 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
>>                         http://www.cgl.ucsf.edu
>> 
>> 
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20150122/9af3bc2a/attachment.html>


More information about the Chimera-dev mailing list