Browse Source

Basis of geometry class + PDB dataset sample with H + Reduce Software binary

Thomas Forest 5 years ago
parent
commit
d653cbda67
5 changed files with 4270 additions and 66 deletions
  1. BIN
      bin/reduce.3.23.130521.linuxi386
  2. 4228 0
      data/1est_H.pdb
  3. 15 37
      src/atom.py
  4. 6 0
      src/geometry.py
  5. 21 29
      src/pdb.py

BIN
bin/reduce.3.23.130521.linuxi386 View File


File diff suppressed because it is too large
+ 4228 - 0
data/1est_H.pdb


+ 15 - 37
src/atom.py View File

@@ -1,41 +1,19 @@
1 1
 class Atom:
2
-
3
-    def __init__(self, ATOM_ID, ATOM_NAME, ALT_LOCAT, RES_NAME, CHAIN_ID,
4
-                 RES_SEQ_NB, RES_INSER_CODE, COORD_X, COORD_Y, COORD_Z,
5
-                 OCCUPANCY, TEMP_FACT, ELEM_SYMBOL, ATOM_CHARGE):
6
-        
7
-        self.ATOM_ID = ATOM_ID
8
-        self.ATOM_NAME = ATOM_NAME
9
-        self.ALT_LOCAT = ALT_LOCAT 
10
-        self.RES_NAME = RES_NAME
11
-        self.CHAIN_ID = CHAIN_ID
12
-        self.RES_SEQ_NB = RES_SEQ_NB
13
-        self.RES_INSER_CODE = RES_INSER_CODE
14
-        self.COORD_X = COORD_X
15
-        self.COORD_Y = COORD_Y
16
-        self.COORD_Z = COORD_Z
17
-        self.OCCUPANCY = OCCUPANCY
18
-        self.TEMP_FACT = TEMP_FACT
19
-        self.ELEM_SYMBOL = ELEM_SYMBOL
20
-        self.ATOM_CHARGE = ATOM_CHARGE
2
+    def __init__(self, atom_id, atom_name, res_name, chain_id,
3
+                 res_seq_nb, coordinates):
4
+        self.atom_id = atom_id
5
+        self.atom_name = atom_name
6
+        self.res_name = res_name
7
+        self.chain_id = chain_id
8
+        self.res_seq_nb = res_seq_nb
9
+        self.coord_x = coordinates[0]
10
+        self.coord_y = coordinates[1]
11
+        self.coord_z = coordinates[2]             
21 12
 
22 13
 class Residue:
23
-    def __init__(self, atomsList):
24
-        self.ATOMS = {}
25
-        for atom in atomsList:
26
-            self.ATOMS[atom.ATOM_NAME] = atom
27
-            if atom.ATOM_NAME == "N":
28
-                self.N = atom
29
-            if atom.ATOM_NAME == "CA":
30
-                self.CA = atom
31
-            if atom.ATOM_NAME == "C":
32
-                self.C = atom
33
-            if atom.ATOM_NAME == "O":
34
-                self.O = atom
35
-            if atom.ATOM_NAME == "CB":
36
-                self.CB = atom
37
-            if atom.ATOM_NAME == "CG1":
38
-                self.CG1 = atom
39
-            if atom.ATOM_NAME == "CG2":
40
-                self.CG2 = atom
14
+    def __init__(self, atoms_list):
15
+        self.atoms = {}
16
+        for atom in atoms_list:
17
+            self.atoms[atom.atom_name] = atom
18
+            
41 19
             

+ 6 - 0
src/geometry.py View File

@@ -0,0 +1,6 @@
1
+class GeomObject:
2
+
3
+    pass
4
+
5
+class Distance:
6
+    

+ 21 - 29
src/pdb.py View File

@@ -1,12 +1,9 @@
1 1
 import sys
2 2
 #import collections
3
-
4
-
5 3
 # custom imports
6 4
 from atom import *
7 5
 
8 6
 class PDBFile:
9
-
10 7
     def getContent(self, filename):
11 8
         with open(filename) as f:
12 9
             return(f.readlines())
@@ -31,36 +28,31 @@ class PDBFile:
31 28
         return(Metadata)
32 29
 
33 30
     def getAtoms(self):
34
-        self.ATOMS = []
35
-        self.RESIDUES = []
36
-        tempAtoms = []
31
+        self.atoms = []
32
+        self.residues = []
33
+        temp_atoms = []
37 34
         for line in self.rawLines:
38 35
             if line.startswith("ATOM" or "HETATM"):
39
-                atom = Atom(ATOM_ID = int(line[6:11].strip()),
40
-                            ATOM_NAME = line[12:16].strip(),
41
-                            ALT_LOCAT = line[16:17].strip(),
42
-                            RES_NAME = line[17:20].strip(),
43
-                            CHAIN_ID = line[21:22].strip(),
44
-                            RES_SEQ_NB = int(line[22:26].strip()),
45
-                            RES_INSER_CODE = line[26:27].strip(),
46
-                            COORD_X = float(line[30:38].strip()),
47
-                            COORD_Y = float(line[38:46].strip()),
48
-                            COORD_Z = float(line[46:54].strip()),
49
-                            OCCUPANCY = float(line[54:60].strip()),
50
-                            TEMP_FACT = float(line[60:66].strip()),
51
-                            ELEM_SYMBOL = line[76:78].strip(),
52
-                            ATOM_CHARGE = line[78:80].strip())
53
-                self.ATOMS.append(atom)
36
+                atom = Atom(atom_id = int(line[6:11].strip()),
37
+                            atom_name = line[12:16].strip(),
38
+                            res_name = line[17:20].strip(),
39
+                            chain_id = line[21:22].strip(),
40
+                            res_seq_nb = int(line[22:26].strip()),
41
+                            coordinates = [float(line[30:38].strip()),
42
+                                     float(line[38:46].strip()),
43
+                                     float(line[46:54].strip()),
44
+                            ])
45
+                self.atoms.append(atom)
54 46
                 # get the current indice of atom
55
-                i = self.ATOMS.index(atom)
47
+                i = self.atoms.index(atom)
56 48
                 # if this is a brand new residue
57
-                if(len(self.ATOMS)>1
58
-                   and atom.RES_SEQ_NB != self.ATOMS[i-1].RES_SEQ_NB):
59
-                    self.RESIDUES.append(Residue(tempAtoms))
60
-                    tempAtoms=[]
61
-                tempAtoms.append(atom)
49
+                if(len(self.atoms)>1
50
+                   and atom.res_seq_nb != self.atoms[i-1].res_seq_nb):
51
+                    self.residues.append(Residue(temp_atoms))
52
+                    temp_atoms=[]
53
+                temp_atoms.append(atom)
62 54
         # last residue
63
-        self.RESIDUES.append(Residue(tempAtoms))
55
+        self.residues.append(Residue(temp_atoms))
64 56
        
65 57
     def __init__(self, filename):
66 58
         self.rawLines = self.getContent(filename)
@@ -76,4 +68,4 @@ if __name__ == "__main__":
76 68
               "call structure and parameters.")
77 69
     else:
78 70
         pdbFile = PDBFile(sys.argv[1])
79
-        print(pdbFile.RESIDUES[0].ATOMS["N"].COORD_X)
71
+        print(pdbFile.residues[15].atoms["C"].coord_x)