<div dir="ltr">Hi Lenna,<div><br></div><div>thanks for the quick answer. It makes perfect sense and now is working. <br><div><br></div><div>Best,</div></div><div><br></div><div>Claudia</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-07-25 14:08 GMT+01:00 Lenna Peterson <span dir="ltr"><<a href="mailto:arklenna@gmail.com" target="_blank">arklenna@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Claudia,<div><br></div><div>Rather than add the residue directly to the structure, you need to add it to a chain. So you will want to do something like `structure[0]["A"].add(...)` (depending on the models/chains in your structure).</div><div><br></div><div>The PDB object in Biopython has 5 hierarchical levels:<br></div><div>Structure</div><div>Model</div><div>Chain</div><div>Residue</div><div>Atom</div><div><br></div><div>The error occurred because the `PDBIO.save` method expects the child of a `Structure` object to be a `Model` object, which has the attribute `serial_num`.</div><div><br></div><div>Let me know if you still run into any problems.</div><div><br></div><div>Cheers,</div><div><br></div><div>Lenna</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Jul 25, 2016 at 7:26 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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Dear all,<div><br></div><div>I am using Biopython to parse a pdb model extracted from a larger pdb and if a condition is met, complete it with some residues from the original pdb model. The residue object that I am trying to add was saved when parsing the original larger pdb, but when I am trying to add it to the new model I am getting this error:</div><div>







<p><span>  File "/Library/Python/2.7/site-packages/biopython-1.66-py2.7-macosx-10.11-intel.egg/Bio/PDB/PDBIO.py", line 187, in save</span></p>
<p><span>    fp.write("MODEL      %s\n" % model.serial_num)</span></p>
<p><span>AttributeError: 'Residue' object has no attribute 'serial_num'</span></p><p><span><br></span></p><p><span>The pdb model that I am completing might have some changes in the chain nomenclature, could that be the reason for the error? But apparently is raised for something related with the model... so I am not sure what is happening.</span></p><p><span>This is the relevant piece of code where the error happens:</span></p><p><span>                        </span><span>if</span><span> add==</span><span>True</span><span> </span><span>and</span><span> checkres!=resi.get_full_id()[-</span><span>1</span><span>]:</span></p><p><span>                              ncheckres=checkres[</span><span>1</span><span>]</span></p><p><span>                              </span><span>print</span><span> </span><span>"Adding ncheckres"</span><span>,ncheckres</span></p><p><span>                              </span><span>print</span><span> </span><span>"dictio_template[ncheckres]['residue_object']"</span><span>,dictio_template[ncheckres][</span><span>'residue_object'</span><span>]</span></p><p><span>                              checkresobj=dictio_template[ncheckres][</span><span>'residue_object'</span><span>]</span></p><p><span>                              </span><span>#print "resi.serial_num",resi.serial_num()</span></p><p><span>                              </span><span>#print "list_res[i+1].serial_num",list_res[i+1].serial_num()</span></p><p><span>                              </span><span>#print "checkresobj.serial_num",checkresobj.serial_num()</span></p><p><span>















</span></p><p><span>                              structure.add(dictio_template[ncheckres][</span><span>'residue_object'</span><span>]) </span></p><p><span>Thanks in advance,</span></p><p><span><br></span></p><p><span>Claudia</span></p></div></div>
<br></div></div>_______________________________________________<br>
Biopython mailing list  -  <a href="mailto:Biopython@mailman.open-bio.org" target="_blank">Biopython@mailman.open-bio.org</a><br>
<a href="http://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biopython</a><br></blockquote></div><br></div>
</blockquote></div><br></div>