[Biopython] Merging different pdbs into a single object structure and writing it

João Rodrigues anaryin at gmail.com
Wed Jun 25 16:23:08 UTC 2014


Ola Claudia,

You don't need to instantiate PDBParser at every structure. Once is enough
followed by calling get_structure() for each structure.

As for the merging, the problem is that set_structure sets one structure
only. What you want is to actually start with an "empty" structure/model
object (you have to create them yourself) and then just append the chains
from your structures to it. If they have different chain identifiers, there
should be no conflict and it should be straightforward.

Does this make sense?

Best,

João


2014-06-25 17:48 GMT+02:00 Claudia Millán Nebot <cmncri at ibmb.csic.es>:

> Hi :) I'm newbie to BioPython and I am trying to do the following:
>
> 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:
>
>             list_parsers=[]
>             list_of_structures=[]
>             for index in range(len(list_of_filenames)):
>                 parser=PDBParser()
>                 list_parsers.append(parser)
>
> structure=parser.get_structure(list_of_filenames[index][:-4],list_of_filenames[index])
>                 list_of_structures.append(structure)
>             i_chain = 65
>             for structure in list_of_structures:
>               for chain in structure:
>                 chain.id = chr(i_chain)
>                 i_chain += 1
>             io=PDBIO()
>             for structure in list_of_structures:
>                 io.set_structure(structure)
>             io.save(clust_fold+key[:-4]+"_fused.pda")
>
> 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?
>
> Thanks in advance and regards,
>
> Claudia Millán (cmncri at ibmb.csic.es)
>
> Crystallographic Methods Group
>
> http://chango.ibmb.csic.es
>
> Institut de Biologia Molecular de Barcelona (IBMB-CSIC)
>
> Barcelona, Spain
>
> _______________________________________________
> Biopython mailing list  -  Biopython at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20140625/3e932628/attachment.html>


More information about the Biopython mailing list