<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi Claudia,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">* You don't need a separate parser for each PDB file, you can just use the same parser object and it will return separate structure objects.<br>
</div><div style="font-family:arial,sans-serif;font-size:13px">* An alternative to using chr on integers would to be to use string.ascii_uppercase</div><div style="font-family:arial,sans-serif;font-size:13px">* Yes, set_structure() is replacing each structure in turn, so you're only writing out the last structure.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">You can only write one structure at a time, so you need to combine multiple structures into different chains in one structure. To do this, you'll need to use the detach_parent() and add() methods. Something like this may work:</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><span style="font-family:arial,sans-serif;font-size:13px">import string</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">index = 0</span><div style="font-family:arial,sans-serif;font-size:13px">
main_structure = list_of_structures[0]<br></div><div style="font-family:arial,sans-serif;font-size:13px"># Set chains in structures and move to first structure<br>for x, structure in enumerate(list_of_structures):<br> for chain in structure:<br>
<a href="http://chain.id/" target="_blank">chain.id</a> = string.ascii_uppercase[index]<br> index += 1</div><div style="font-family:arial,sans-serif;font-size:13px"> # Don't move chains of first structure</div>
<div style="font-family:arial,sans-serif;font-size:13px"> if x == 0: continue<br> chain.detach_parent()<br><div> main_structure[0].add(chain)</div><div><br></div><div>Let me know whether or not that works for you.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Lenna</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 25, 2014 at 11:48 AM, Claudia Millán Nebot <span dir="ltr"><<a href="mailto:cmncri@ibmb.csic.es" target="_blank">cmncri@ibmb.csic.es</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi :) I'm newbie to BioPython and I am trying to do the following:<div><br></div><div>I have a set of different pdbs that I want to merge together into a single file. I would like to take into consideration that there could be issues with the naming, so, after reading a few other posts in this same list, I came up with the following code:</div>
<div><br></div><div><div> list_parsers=[]</div><div> list_of_structures=[]</div><div> for index in range(len(list_of_filenames)):</div><div> parser=PDBParser()</div><div> list_parsers.append(parser)</div>
<div> structure=parser.get_structure(list_of_filenames[index][:-4],list_of_filenames[index])</div><div> list_of_structures.append(structure)</div><div> i_chain = 65</div><div> for structure in list_of_structures:</div>
<div> for chain in structure:</div><div> <a href="http://chain.id" target="_blank">chain.id</a> = chr(i_chain)</div><div> i_chain += 1</div><div> io=PDBIO() </div>
<div> for structure in list_of_structures:</div>
<div> io.set_structure(structure)</div><div> io.save(clust_fold+key[:-4]+"_fused.pda")</div><div><br></div><div>This is not working, as I guess i'm just changing the structure set each time I do io.set_structure, and writing the last one. And as there is not such a thing as the append_structure() method I have just tried a silly thing. So my question would be which is the best way to get the pdbs merged? Should I save as independent unfold entities and then write them by using a Select class?</div>
<div><br></div><div>Thanks in advance and regards,</div><div><div><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse;color:rgb(34,34,34)"><p><font face="arial, helvetica, sans-serif">Claudia Millán (<a href="mailto:cmncri@ibmb.csic.es" style="color:rgb(17,85,204)" target="_blank">cmncri@ibmb.csic.es</a>)</font></p>
<p><font face="arial, helvetica, sans-serif">Crystallographic Methods Group</font></p><p><font face="arial, helvetica, sans-serif"> <a href="http://chango.ibmb.csic.es" target="_blank">http://chango.ibmb.csic.es</a> <br>
</font></p>
<p><font face="arial, helvetica, sans-serif">Institut de Biologia Molecular de Barcelona (IBMB-CSIC)</font></p><p><font face="arial, helvetica, sans-serif">Barcelona, Spain</font></p></span></div></div>
</div></div></div>
<br>_______________________________________________<br>
Biopython mailing list - <a href="mailto:Biopython@mailman.open-bio.org">Biopython@mailman.open-bio.org</a><br>
<a href="http://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biopython</a><br></blockquote></div><br></div>