<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I forget that in Python 2, division is “integer division” and truncates to an integer (unlike Python 3). So these lines:<div class=""><br class=""></div><div class=""><i class=""><span class="Apple-tab-span" style="white-space:pre"> </span>helix_fract = len([r for r in mol.residues if r.isHelix]) / len(mol.residues)<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>sheet_fract = len([r for r in mol.residues if r.isSheet]) / len(mol.residues)</i></div><div class=""><br class=""></div><div class="">need to be instead:</div><div class=""><br class=""></div><div class=""><i class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>helix_fract = len([r for r in mol.residues if r.isHelix]) / float(len(mol.residues))<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>sheet_fract = len([r for r in mol.residues if r.isSheet]) / float(len(mol.residues))</i></div><div class=""><i class=""><br class=""></i></div><div class="">—Eric</div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>Eric Pettersen</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>UCSF Computer Graphics Lab</div><div class=""><br class=""></div></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Oct 11, 2016, at 4:01 AM, Healey, Joe <<a href="mailto:J.R.J.Healey@warwick.ac.uk" class="">J.R.J.Healey@warwick.ac.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="divtagdefaultwrapper" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class="">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.</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">I've got the following based on your snippet, but for some reason it is giving me zeros for helix and turn:</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>chimera.openModels.open(args.infile,type="PDB")</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>with open(args.outfile, "w") as outputFile:</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>for mol in openModels.list(modelTypes=[Molecule]):</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>helix_fract = len([r for r in mol.residues if r.isHelix]) / len(mol.residues)</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>sheet_fract = len([r for r in mol.residues if r.isSheet]) / len(mol.residues)</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>other_fract = (1 - (helix_fract + sheet_fract))</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>print(args.infile + "\t" + str(helix_fract) + "\t" + str(sheet_fract) + "\t" + str(other_fract))</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>outputFile.write(args.infile + "\t" + str(helix_fract) + "\t" + str(sheet_fract) + "\t" + str(other_fract) + "\n")</div><div class=""><br class=""></div>What am I missing here?<p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Thanks</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Joe</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">Joe Healey</span><br class=""></div><div id="Signature" class=""><div id="divtagdefaultwrapper" style="font-size: 12pt; background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><br class=""></div><div id="divtagdefaultwrapper" style="font-size: 12pt; background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="text-decoration: underline;" class=""> <span class="Apple-converted-space"> </span></span><br class=""></div><div id="divtagdefaultwrapper" style="font-size: 12pt; background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="font-size: 10pt;" class="">M.Sc. B.Sc. (Hons)</span><br class=""></div><div id="divtagdefaultwrapper" style="font-size: 12pt; background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="font-size: 10pt;" class=""></span><div class=""><span style="font-size: 10pt;" class="">PhD Student</span></div><div class=""><span style="font-size: 10pt;" class="">MOAC CDT, Senate House</span></div><div class=""><span style="font-size: 10pt;" class="">University of Warwick<br class=""></span></div><div class=""><span style="font-size: 10pt;" class="">Coventry<br class=""></span></div><div class=""><span style="font-size: 10pt;" class="">CV47AL<br class="">Mob: +44 (0) 7536 042620 | </span><span style="font-size: 10pt;" class="">Email:<span class="Apple-converted-space"> </span><a href="mailto:J.R.J.Healey@warwick.ac.uk" class="">J.R.J.Healey@warwick.ac.uk</a></span></div><div class=""><span style="font-size: 10pt;" class=""><br class=""></span></div><div class=""><span style="font-size: 10pt;" class="">Jointly working in:<br class=""></span></div><div class=""><span style="font-size: 10pt;" class=""><a href="http://www2.warwick.ac.uk/fac/med/research/tsm/microinfect/staff/waterfieldlab/" id="LPNoLP" class="">Waterfield Lab</a><span class="Apple-converted-space"> </span>(<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333330154419px; background-color: rgb(255, 255, 255);" class="">WMS </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333330154419px; background-color: rgb(255, 255, 255);" class="">Microbiology and Infecti</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333330154419px; background-color: rgb(255, 255, 255);" class="">on Un</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 13.3333330154419px; background-color: rgb(255, 255, 255);" class="">it)</span></span></div><div class=""><span style="font-size: 10pt;" class="">and the <a href="http://www2.warwick.ac.uk/fac/sci/chemistry/research/gibson/gibsongroup/" id="LPNoLP" class="">Gibson Lab</a> (Warwick Chemistry)<br class=""></span></div><div class=""><span style="font-size: 10pt;" class=""><br class=""></span></div><div class=""><span style="font-size: 10pt;" class="">Twitter:<span class="Apple-converted-space"> </span><a href="https://twitter.com/JRJHealey" id="LPNoLP" class="">@JRJHealey</a> | </span><span style="font-size: 10pt;" class="">Website:<span class="Apple-converted-space"> </span></span><a href="http://www2.warwick.ac.uk/fac/sci/moac/people/students/2013/joseph_healey" id="LPNoLP" style="font-size: 10pt;" class="">MOAC Page</a></div></div></div></div><hr tabindex="-1" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline-block; width: 637px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""></span><div id="divRplyFwdMsg" dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span>Eric Pettersen <<a href="mailto:pett@cgl.ucsf.edu" class="">pett@cgl.ucsf.edu</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>10 October 2016 18:54:08<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Healey, Joe<br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span>chimera List<br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [Chimera-users] Computing 'basic' structure characteristics</font><div class=""> </div></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><blockquote type="cite" class=""><div class="">On Oct 9, 2016, at 9:53 AM, Elaine Meng <<a href="mailto:meng@cgl.ucsf.edu" class="">meng@cgl.ucsf.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">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.).</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">I can’t help with the Python side, this is just the perspective from the commands side. All the commands I mentioned are documented,</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;"><</span><a href="http://www.rbvi.ucsf.edu/chimera/docs/UsersGuide/framecommand.html" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">http://www.rbvi.ucsf.edu/chimera/docs/UsersGuide/framecommand.html</a><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">></span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div></blockquote><br class=""></div><div class="">To supplement this part of the answer, you can loop through a bunch of PDB files in Python as outlined here:</div><div class=""><br class=""></div><a href="http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/basicPrimer.html" class="">http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/basicPrimer.html</a><div class=""><br class=""></div><div class="">You can determine the fraction of residues in helix and sheet with code like this:</div><div class=""><br class=""></div><div class=""><i class="">from chimera import openModels, Molecule</i></div><div class=""><i class=""><br class=""></i></div><div class=""><i class=""><span class="Apple-tab-span" style="white-space: pre;"></span>#… inside the loop…</i></div><div class=""><i class=""><span class="Apple-tab-span" style="white-space: pre;"></span>for mol in openModels.list(modelTypes=[Molecule]):</i></div><div class=""><div class=""><i class=""><span class="Apple-tab-span" style="white-space: pre;"></span>sheet_fract = len([r for r in mol.residues if r.isSheet]) / len(mol.residues)</i></div></div><div class=""><div class=""><i class=""><span class="Apple-tab-span" style="white-space: pre;"></span>helix_fract = len([r for r in mol.residues if r.isHelix]) / len(mol.residues)</i></div></div><div class=""><i class=""><span class="Apple-tab-span" style="white-space: pre;"></span># write them to a file with “print>>f” or to the reply log with just “print”</i></div><div class=""><br class=""></div><div class="">The above assumes you have a little bit of familiarity with Python. I can provide more explanation if you need it.</div><div class=""><br class=""></div><div class="">—Eric</div><div class=""><br class=""></div><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>Eric Pettersen</div><div class=""><span class="Apple-tab-span" style="white-space: pre;"></span>UCSF Computer Graphics Lab</div></div></div></div></div></div></blockquote></div><br class=""></div></body></html>