0
#!/usr/bin/env python2.7 
##-*- mode:python;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t;python-indent:2 -*-'

import noesy
import argparse
import library

parser =argparse.ArgumentParser(description="read pdb file",
                                add_help=True)

parser.add_argument("file",help="protein pdb file")

library.add_standard_args( parser )
args = parser.parse_args()

def read_structure(pdbfile):
        struct=[]
        for line in pdbfile:
                if len(line):
                        struct.append(PDBAttributes.read_from_line(line))
        return struct

pdb=read_structure(open(args.file,'r'))

class PDBAttributes:
    def __init__(self, atomindex=1, atom=noesy.Atom(), atomx=1, atomy=1, atomz=1):
        self._atomindex=atomindex
        self._atom=atom
        self._atomx=atomx
        self._atomy=atomy
        self._atomz=atomz

        def __str__(self):
        s='ATOM %(_atomindex)d %(_atom)s at %(_atomx)8.3f %(_atomy)8.3f %(_atomz)8.3f'%self.__dict__
        return s

    def atom(self):
        return self._atom

    def atomindex(self):
        return self._atomindex

    def atomx(self):
        return self._atomx

    def atomy(self):
        return self._atomy

    def atomz(self):
        return self._atomz

    @classmethod
    def read_from_line(obj,line):
        tags=line.split()
        atomindex=int(tags[1])
        atom=noesy.Atom(tags[2],int(tags[5]))
        atomx=float(tags[6])
        atomy=float(tags[7])
        atomz=float(tags[8])
        obj=PDBAttributes(atomindex, atom, atomx, atomy, atomz)
        print obj

class AtomDistance(PDBAttributes):

    def distance(self, atom1,atom2):
        pass
4

2 に答える 2