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:
|
class Atom:
|
||||||
|
def __init__(self, atom_id, atom_name, res_name, chain_id,
|
||||||
def __init__(self, ATOM_ID, ATOM_NAME, ALT_LOCAT, RES_NAME, CHAIN_ID,
|
res_seq_nb, coordinates):
|
||||||
RES_SEQ_NB, RES_INSER_CODE, COORD_X, COORD_Y, COORD_Z,
|
self.atom_id = atom_id
|
||||||
OCCUPANCY, TEMP_FACT, ELEM_SYMBOL, ATOM_CHARGE):
|
self.atom_name = atom_name
|
||||||
|
self.res_name = res_name
|
||||||
self.ATOM_ID = ATOM_ID
|
self.chain_id = chain_id
|
||||||
self.ATOM_NAME = ATOM_NAME
|
self.res_seq_nb = res_seq_nb
|
||||||
self.ALT_LOCAT = ALT_LOCAT
|
self.coord_x = coordinates[0]
|
||||||
self.RES_NAME = RES_NAME
|
self.coord_y = coordinates[1]
|
||||||
self.CHAIN_ID = CHAIN_ID
|
self.coord_z = coordinates[2]
|
||||||
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
|
|
||||||
|
|
||||||
class Residue:
|
class Residue:
|
||||||
def __init__(self, atomsList):
|
def __init__(self, atoms_list):
|
||||||
self.ATOMS = {}
|
self.atoms = {}
|
||||||
for atom in atomsList:
|
for atom in atoms_list:
|
||||||
self.ATOMS[atom.ATOM_NAME] = atom
|
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
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
class GeomObject:
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Distance:
|
||||||
|
|
||||||
50
src/pdb.py
50
src/pdb.py
|
|
@ -1,12 +1,9 @@
|
||||||
import sys
|
import sys
|
||||||
#import collections
|
#import collections
|
||||||
|
|
||||||
|
|
||||||
# custom imports
|
# custom imports
|
||||||
from atom import *
|
from atom import *
|
||||||
|
|
||||||
class PDBFile:
|
class PDBFile:
|
||||||
|
|
||||||
def getContent(self, filename):
|
def getContent(self, filename):
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
return(f.readlines())
|
return(f.readlines())
|
||||||
|
|
@ -31,36 +28,31 @@ class PDBFile:
|
||||||
return(Metadata)
|
return(Metadata)
|
||||||
|
|
||||||
def getAtoms(self):
|
def getAtoms(self):
|
||||||
self.ATOMS = []
|
self.atoms = []
|
||||||
self.RESIDUES = []
|
self.residues = []
|
||||||
tempAtoms = []
|
temp_atoms = []
|
||||||
for line in self.rawLines:
|
for line in self.rawLines:
|
||||||
if line.startswith("ATOM" or "HETATM"):
|
if line.startswith("ATOM" or "HETATM"):
|
||||||
atom = Atom(ATOM_ID = int(line[6:11].strip()),
|
atom = Atom(atom_id = int(line[6:11].strip()),
|
||||||
ATOM_NAME = line[12:16].strip(),
|
atom_name = line[12:16].strip(),
|
||||||
ALT_LOCAT = line[16:17].strip(),
|
res_name = line[17:20].strip(),
|
||||||
RES_NAME = line[17:20].strip(),
|
chain_id = line[21:22].strip(),
|
||||||
CHAIN_ID = line[21:22].strip(),
|
res_seq_nb = int(line[22:26].strip()),
|
||||||
RES_SEQ_NB = int(line[22:26].strip()),
|
coordinates = [float(line[30:38].strip()),
|
||||||
RES_INSER_CODE = line[26:27].strip(),
|
float(line[38:46].strip()),
|
||||||
COORD_X = float(line[30:38].strip()),
|
float(line[46:54].strip()),
|
||||||
COORD_Y = float(line[38:46].strip()),
|
])
|
||||||
COORD_Z = float(line[46:54].strip()),
|
self.atoms.append(atom)
|
||||||
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)
|
|
||||||
# get the current indice of 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 this is a brand new residue
|
||||||
if(len(self.ATOMS)>1
|
if(len(self.atoms)>1
|
||||||
and atom.RES_SEQ_NB != self.ATOMS[i-1].RES_SEQ_NB):
|
and atom.res_seq_nb != self.atoms[i-1].res_seq_nb):
|
||||||
self.RESIDUES.append(Residue(tempAtoms))
|
self.residues.append(Residue(temp_atoms))
|
||||||
tempAtoms=[]
|
temp_atoms=[]
|
||||||
tempAtoms.append(atom)
|
temp_atoms.append(atom)
|
||||||
# last residue
|
# last residue
|
||||||
self.RESIDUES.append(Residue(tempAtoms))
|
self.residues.append(Residue(temp_atoms))
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
self.rawLines = self.getContent(filename)
|
self.rawLines = self.getContent(filename)
|
||||||
|
|
@ -76,4 +68,4 @@ if __name__ == "__main__":
|
||||||
"call structure and parameters.")
|
"call structure and parameters.")
|
||||||
else:
|
else:
|
||||||
pdbFile = PDBFile(sys.argv[1])
|
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