[Chimera-users] Computing 'basic' structure characteristics
Eric Pettersen
pett at cgl.ucsf.edu
Tue Oct 11 10:43:16 PDT 2016
I forget that in Python 2, division is “integer division” and truncates to an integer (unlike Python 3). So these lines:
helix_fract = len([r for r in mol.residues if r.isHelix]) / len(mol.residues)
sheet_fract = len([r for r in mol.residues if r.isSheet]) / len(mol.residues)
need to be instead:
helix_fract = len([r for r in mol.residues if r.isHelix]) / float(len(mol.residues))
sheet_fract = len([r for r in mol.residues if r.isSheet]) / float(len(mol.residues))
—Eric
Eric Pettersen
UCSF Computer Graphics Lab
> On Oct 11, 2016, at 4:01 AM, Healey, Joe <J.R.J.Healey at warwick.ac.uk> wrote:
>
> Nevermind, I think you can ignore my last email. Chimera wasn't recognising the 'isTurn' attribute so I guess that's my answer. I'll just define turn/other as 1-(everything else) which should suffice.
>
> I've got the following based on your snippet, but for some reason it is giving me zeros for helix and turn:
>
> chimera.openModels.open(args.infile,type="PDB")
>
> with open(args.outfile, "w") as outputFile:
> for mol in openModels.list(modelTypes=[Molecule]):
> helix_fract = len([r for r in mol.residues if r.isHelix]) / len(mol.residues)
> sheet_fract = len([r for r in mol.residues if r.isSheet]) / len(mol.residues)
> other_fract = (1 - (helix_fract + sheet_fract))
> print(args.infile + "\t" + str(helix_fract) + "\t" + str(sheet_fract) + "\t" + str(other_fract))
> outputFile.write(args.infile + "\t" + str(helix_fract) + "\t" + str(sheet_fract) + "\t" + str(other_fract) + "\n")
>
> What am I missing here?
>
> Thanks
>
> Joe
>
> Joe Healey
>
>
> M.Sc. B.Sc. (Hons)
> PhD Student
> MOAC CDT, Senate House
> University of Warwick
> Coventry
> CV47AL
> Mob: +44 (0) 7536 042620 | Email: J.R.J.Healey at warwick.ac.uk <mailto:J.R.J.Healey at warwick.ac.uk>
>
> Jointly working in:
> Waterfield Lab <http://www2.warwick.ac.uk/fac/med/research/tsm/microinfect/staff/waterfieldlab/> (WMS Microbiology and Infection Unit)
> and the Gibson Lab <http://www2.warwick.ac.uk/fac/sci/chemistry/research/gibson/gibsongroup/> (Warwick Chemistry)
>
> Twitter: @JRJHealey <https://twitter.com/JRJHealey> | Website: MOAC Page <http://www2.warwick.ac.uk/fac/sci/moac/people/students/2013/joseph_healey>
> From: Eric Pettersen <pett at cgl.ucsf.edu>
> Sent: 10 October 2016 18:54:08
> To: Healey, Joe
> Cc: chimera List
> Subject: Re: [Chimera-users] Computing 'basic' structure characteristics
>
>> On Oct 9, 2016, at 9:53 AM, Elaine Meng <meng at cgl.ucsf.edu <mailto:meng at cgl.ucsf.edu>> wrote:
>>
>> If you just want to look at predominance of secondary structures, you would not use those integers which mean first strand, second strand, first helix, etc. Instead you could just see how many residues are already assigned as strand, helix, and coil. There aren’t commands to do this directly, only some very cumbersome approaches that I imagine are vastly inferior to using Python (like “select strand” and then writing a list of all those residues with “writesel” etc.).
>>
>> I can’t help with the Python side, this is just the perspective from the commands side. All the commands I mentioned are documented,
>> <http://www.rbvi.ucsf.edu/chimera/docs/UsersGuide/framecommand.html <http://www.rbvi.ucsf.edu/chimera/docs/UsersGuide/framecommand.html>>
>
> To supplement this part of the answer, you can loop through a bunch of PDB files in Python as outlined here:
>
> http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/basicPrimer.html <http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/basicPrimer.html>
>
> You can determine the fraction of residues in helix and sheet with code like this:
>
> from chimera import openModels, Molecule
>
> #… inside the loop…
> for mol in openModels.list(modelTypes=[Molecule]):
> sheet_fract = len([r for r in mol.residues if r.isSheet]) / len(mol.residues)
> helix_fract = len([r for r in mol.residues if r.isHelix]) / len(mol.residues)
> # write them to a file with “print>>f” or to the reply log with just “print”
>
> The above assumes you have a little bit of familiarity with Python. I can provide more explanation if you need it.
>
> —Eric
>
> Eric Pettersen
> UCSF Computer Graphics Lab
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20161011/7c4e3f10/attachment.html>
More information about the Chimera-users
mailing list