[Biopython-dev] Parsing "element" out of PDB file

João Rodrigues anaryin at gmail.com
Wed Jun 23 16:52:47 UTC 2010


Ok, I've changed it in my local branch to if not element since that covers
both None and empty strings.

Best,

João [...] Rodrigues
@ http://doeidoei.wordpress.org



On Wed, Jun 23, 2010 at 4:11 AM, Peter <biopython at maubp.freeserve.co.uk>wrote:

> On Tue, Jun 22, 2010 at 8:25 PM, João Rodrigues <anaryin at gmail.com> wrote:
> > Hello all,
> >
> > I've been using some non-standard pdb files outputted by some programs
> and
> > they miss the chemical element column in each ATOM line. I was looking at
> > the PDBParser code and element is dealt with like this:
> >
> >        if element is None:
> >            import warnings
> >            from PDBExceptions import PDBConstructionWarning
> >            warnings.warn("Atom object (name=%s) without element" % name,
> >                          PDBConstructionWarning)
> >            element = "?"
> >            print name, "--> ?"
> >        elif len(element)>2 or element != element.upper() or element !=
> > element.strip():
> >            raise ValueError(element)
> >        self.element=element
> >
> >
> > In my case, the element line is not "None" but just an empty string - ' '
> -
> > which fails these tests and is then passed on.
>
> That makes sense, since element=line[76:78].strip() will give an empty
> string. A change as you suggest makes sense, but I think just using
> "if element:" would be nicer.
>
> Peter
>




More information about the Biopython-dev mailing list