[BioPython] suggestions for Bio.PDB

Catherine Letondal letondal at pasteur.fr
Sat Apr 16 11:13:47 EDT 2005


Hi,

Would it be possible for the get_structure() method in PDBParser to 
accept a filehandle, instead of just accepting just a filename?
That would be very nice to enable different origins for data (an url, a 
string + StringIO, a pipe, ...).

Another suggestion: it could be useful to keep a record of the read 
structure, just in case the user would like to benefit from biopython  
PDB modules, but also do some custom analysis.

My suggestions could be impleted like this:

     def get_structure(self, id, filename=None, filehandle=None):
         """Return the structure.

         Arguments:
         o id - string, the id that will be used for the structure
         o filename - name of the PDB file
         o filehandle - a filehandle on a PDB structure
         """
         self.header=None
         self.trailer=None
         # Make a StructureBuilder instance (pass id of structure as 
parameter)
         self.structure_builder.init_structure(id)
         if filename is None:
             file=open(filename)
         elif filehandle is not None:
             file = filehandle
         else:
             return None
         pdb_lines = file.readlines()
         self.pdb_text = "".join(pdb_lines)
         self._parse(pdb_lines)
         if filehandle is None:
             file.close()
         self.structure_builder.set_header(self.header)
         # Return the Structure instance
         return self.structure_builder.get_structure()


Thanks for providing this biopython PDB modules!


--
Catherine Letondal -- Institut Pasteur
www.pasteur.fr/~letondal



More information about the BioPython mailing list