Basis of geometry class + PDB dataset sample with H + Reduce Software binary
parent
f19f25a3bf
commit
d653cbda67
Binary file not shown.
File diff suppressed because it is too large
Load Diff
52
src/atom.py
52
src/atom.py
|
|
@ -1,41 +1,19 @@
|
|||
class Atom:
|
||||
|
||||
def __init__(self, ATOM_ID, ATOM_NAME, ALT_LOCAT, RES_NAME, CHAIN_ID,
|
||||
RES_SEQ_NB, RES_INSER_CODE, COORD_X, COORD_Y, COORD_Z,
|
||||
OCCUPANCY, TEMP_FACT, ELEM_SYMBOL, ATOM_CHARGE):
|
||||
|
||||
self.ATOM_ID = ATOM_ID
|
||||
self.ATOM_NAME = ATOM_NAME
|
||||
self.ALT_LOCAT = ALT_LOCAT
|
||||
self.RES_NAME = RES_NAME
|
||||
self.CHAIN_ID = CHAIN_ID
|
||||
self.RES_SEQ_NB = RES_SEQ_NB
|
||||
self.RES_INSER_CODE = RES_INSER_CODE
|
||||
self.COORD_X = COORD_X
|
||||
self.COORD_Y = COORD_Y
|
||||
self.COORD_Z = COORD_Z
|
||||
self.OCCUPANCY = OCCUPANCY
|
||||
self.TEMP_FACT = TEMP_FACT
|
||||
self.ELEM_SYMBOL = ELEM_SYMBOL
|
||||
self.ATOM_CHARGE = ATOM_CHARGE
|
||||
def __init__(self, atom_id, atom_name, res_name, chain_id,
|
||||
res_seq_nb, coordinates):
|
||||
self.atom_id = atom_id
|
||||
self.atom_name = atom_name
|
||||
self.res_name = res_name
|
||||
self.chain_id = chain_id
|
||||
self.res_seq_nb = res_seq_nb
|
||||
self.coord_x = coordinates[0]
|
||||
self.coord_y = coordinates[1]
|
||||
self.coord_z = coordinates[2]
|
||||
|
||||
class Residue:
|
||||
def __init__(self, atomsList):
|
||||
self.ATOMS = {}
|
||||
for atom in atomsList:
|
||||
self.ATOMS[atom.ATOM_NAME] = atom
|
||||
if atom.ATOM_NAME == "N":
|
||||
self.N = atom
|
||||
if atom.ATOM_NAME == "CA":
|
||||
self.CA = atom
|
||||
if atom.ATOM_NAME == "C":
|
||||
self.C = atom
|
||||
if atom.ATOM_NAME == "O":
|
||||
self.O = atom
|
||||
if atom.ATOM_NAME == "CB":
|
||||
self.CB = atom
|
||||
if atom.ATOM_NAME == "CG1":
|
||||
self.CG1 = atom
|
||||
if atom.ATOM_NAME == "CG2":
|
||||
self.CG2 = atom
|
||||
def __init__(self, atoms_list):
|
||||
self.atoms = {}
|
||||
for atom in atoms_list:
|
||||
self.atoms[atom.atom_name] = atom
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
class GeomObject:
|
||||
|
||||
pass
|
||||
|
||||
class Distance:
|
||||
|
||||
50
src/pdb.py
50
src/pdb.py
|
|
@ -1,12 +1,9 @@
|
|||
import sys
|
||||
#import collections
|
||||
|
||||
|
||||
# custom imports
|
||||
from atom import *
|
||||
|
||||
class PDBFile:
|
||||
|
||||
def getContent(self, filename):
|
||||
with open(filename) as f:
|
||||
return(f.readlines())
|
||||
|
|
@ -31,36 +28,31 @@ class PDBFile:
|
|||
return(Metadata)
|
||||
|
||||
def getAtoms(self):
|
||||
self.ATOMS = []
|
||||
self.RESIDUES = []
|
||||
tempAtoms = []
|
||||
self.atoms = []
|
||||
self.residues = []
|
||||
temp_atoms = []
|
||||
for line in self.rawLines:
|
||||
if line.startswith("ATOM" or "HETATM"):
|
||||
atom = Atom(ATOM_ID = int(line[6:11].strip()),
|
||||
ATOM_NAME = line[12:16].strip(),
|
||||
ALT_LOCAT = line[16:17].strip(),
|
||||
RES_NAME = line[17:20].strip(),
|
||||
CHAIN_ID = line[21:22].strip(),
|
||||
RES_SEQ_NB = int(line[22:26].strip()),
|
||||
RES_INSER_CODE = line[26:27].strip(),
|
||||
COORD_X = float(line[30:38].strip()),
|
||||
COORD_Y = float(line[38:46].strip()),
|
||||
COORD_Z = float(line[46:54].strip()),
|
||||
OCCUPANCY = float(line[54:60].strip()),
|
||||
TEMP_FACT = float(line[60:66].strip()),
|
||||
ELEM_SYMBOL = line[76:78].strip(),
|
||||
ATOM_CHARGE = line[78:80].strip())
|
||||
self.ATOMS.append(atom)
|
||||
atom = Atom(atom_id = int(line[6:11].strip()),
|
||||
atom_name = line[12:16].strip(),
|
||||
res_name = line[17:20].strip(),
|
||||
chain_id = line[21:22].strip(),
|
||||
res_seq_nb = int(line[22:26].strip()),
|
||||
coordinates = [float(line[30:38].strip()),
|
||||
float(line[38:46].strip()),
|
||||
float(line[46:54].strip()),
|
||||
])
|
||||
self.atoms.append(atom)
|
||||
# get the current indice of atom
|
||||
i = self.ATOMS.index(atom)
|
||||
i = self.atoms.index(atom)
|
||||
# if this is a brand new residue
|
||||
if(len(self.ATOMS)>1
|
||||
and atom.RES_SEQ_NB != self.ATOMS[i-1].RES_SEQ_NB):
|
||||
self.RESIDUES.append(Residue(tempAtoms))
|
||||
tempAtoms=[]
|
||||
tempAtoms.append(atom)
|
||||
if(len(self.atoms)>1
|
||||
and atom.res_seq_nb != self.atoms[i-1].res_seq_nb):
|
||||
self.residues.append(Residue(temp_atoms))
|
||||
temp_atoms=[]
|
||||
temp_atoms.append(atom)
|
||||
# last residue
|
||||
self.RESIDUES.append(Residue(tempAtoms))
|
||||
self.residues.append(Residue(temp_atoms))
|
||||
|
||||
def __init__(self, filename):
|
||||
self.rawLines = self.getContent(filename)
|
||||
|
|
@ -76,4 +68,4 @@ if __name__ == "__main__":
|
|||
"call structure and parameters.")
|
||||
else:
|
||||
pdbFile = PDBFile(sys.argv[1])
|
||||
print(pdbFile.RESIDUES[0].ATOMS["N"].COORD_X)
|
||||
print(pdbFile.residues[15].atoms["C"].coord_x)
|
||||
|
|
|
|||
Loading…
Reference in New Issue