-
Notifications
You must be signed in to change notification settings - Fork 0
/
prBubble.py
36 lines (31 loc) · 1.55 KB
/
prBubble.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from shapely.geometry import Polygon
import random
#general function to move a vector
def moveVector(point, distance):
return tuple(map(sum,zip(point,distance)))
#Defining a protein
#ThOrigin: The protein will be shifted (random(-ThOrigin,ThOrigin), random(-ThOrigin,ThOrigin)) from its original coordinates.
#type: type of template protein
#ip: protein index used to create the ID
#ib: bubble index used to create the ID
#nature: could be O (original), H (hybrid) or D (dissociated)
#status: 1:active 0:inactive. The protein is inactive when it merged with another and one is discarded
#baseTemplate: coordinates of the base protein(s) forming this protein. 0 = Original template found in baseProteins list.
#allowedTypes: protein types missing to complete a cell wall
# We should have a 'structure' property which would be a list of joined proteins
class Protein:
def __init__(self, baseproteins, type, ip, ib, ThOrigin=100):
self.type = type
self.id = "B" + str(ib) + "T" + str(type) + "P" + str(ip)
#self.ThOrigin = ThOrigin #should be removed from here
self.originshift = (random.uniform(-ThOrigin, ThOrigin), random.uniform(-ThOrigin, ThOrigin))
self.coords = [moveVector(x, self.originshift) for x in baseproteins[type]]
self.nature = "O"
self.status = 1
self.baseTemplate = 0
self.allowedTypes = filter(lambda a: a !=self.type, [1,2,3,4,5])
#Moving a whole protein structure
def move(self, vector):
self.coords = [moveVector(x, vector) for x in self.coords]
def dist(self, element):
return Polygon(self.coords).distance(Polygon(element.coords))