-
Notifications
You must be signed in to change notification settings - Fork 1
/
postgroupcavities.py
executable file
·164 lines (126 loc) · 5.94 KB
/
postgroupcavities.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env python
#
# This file is part of the dxTuber package
# Copyright (C) 2010-2013 Martin Raunest
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# v0.23
# +distcutoff parameter can now be set via cmd
#
#
# v0.2
# + shell script to postgroup cavities into subcavities.
#
#
#
import os
import subprocess
from lib.readpdb import *
from lib.writepdb import *
from lib.buildopendx import *
from lib.tubedx import *
from lib.postgroup import *
#########
# Get dxTuber settings
#########
dxTuberConfFile = os.environ['HOME']+"/.dxTuber/dxTuber.conf"
conf = open (dxTuberConfFile,'r')
confLines = conf.readlines()
for line in confLines:
if re.match ('^#',line):
continue
if re.match('VERSION',line):
tmpArray = re.split('\s',line,1)
tmp = re.sub('\"','',tmpArray[1])
tmp = re.sub('\n','',tmp)
version = re.sub('^\s','',tmp)
####
# Deal with arguments
####
######################################################################
# If argparse is not installed global, get a static lib #
# and import it manually (static) #
# #
# http://packages.ubuntu.com/lucid/python-argparse #
# http://code.google.com/p/argparse/ #
# #
# maybe this helps for implementation ... #
# #
# sys.path.append('path_to_argparse_lib')
# from argparse import *
# #
######################################################################
try:
import argparse
parser = argparse.ArgumentParser(description='''"--cubicsize" defines the number of voxels in each direction, e.g: 2 => 2 in +x and -x, +y and -y, +z and -z direction defining a 5x5x5 cube with 125 voxels
"-t" sets the minimum amount of neighboars in the "--cubicsize" defined cube as a threshold for the core cavities''',
epilog='There is no spoon',formatter_class=argparse.RawTextHelpFormatter )
except ImportError :
sys.path.append('/home/bit/raunest/programms/python/scripts/lib') ## if argparse is not installed global you can use it in a static way
from argparse import *
parser = ArgumentParser(description='"--cubicsize" defines the number of voxels in each direction, e.g: 2 => 2 in +x and -x, +y and -y, +z and -z direction defining a 5x5x5 cube with 125 voxels\n\n"-t" sets the minimum amount of neighboars in the "--cubicsize" defined cube as a threshold for the core cavities',epilog='There is no spoon',formatter_class=RawTextHelpFormatter )
parser.add_argument('--ipdb', default=False,help='PDB inputfile (only previously via dxTuber created pdb files are supported)')
parser.add_argument('--opdb', default=False, help='PDB outfile')
parser.add_argument('--cid', default='all', help='Cavity ID to postgroup, use "all" if all cavities should be processed (default="all")')
parser.add_argument('--cubicsize', default='2', help='edge length default 2 Voxels => Volume => 125 Voxels ... [INT] ')
parser.add_argument('-t','--threshold', default='100', help='Minimum amount of neighbors in --cubicsize to calc "core" cavities (default = 100)')
parser.add_argument('-d','--distcutoff', default='8', help='Cubic size for reprouping the non core voxels. This routine checks each core voxel per default in +8 and -8 in xyz for non core ISVs.')
args = parser.parse_args()
if not args.ipdb or not args.opdb:
sysRun = subprocess.Popen([sys.argv[0], '-h'])
sysRun.communicate()
print "Please specify input and output by '--ipdb' and '--opdb'\n"
sys.exit()
readPDB = ReadPDB(args.ipdb)
readPDB.readPDB()
cavitiesTubeObject = readPDB.getTubeDxObject()
cavitiesDxObject = readPDB.getDxObject()
### Densities contain now information about each voxels " neighborhood "
postGroup = PostGroup ( cavitiesTubeObject )
#oke testing now :)
# postGroupDensities = postGroup.calcNeighbors(cavityID = args.cid, edgeLength = int(args.cubicsize)) <-- works fine !
# postGroupDxObject = BuildOpenDx (density = postGroupDensities,
# stepSize = cavitiesDxObject.getStepsize(),
# origin = cavitiesDxObject.getOrigin(),
# dimention = cavitiesDxObject.getDimention())
#
'''
postGroupTubeDx = TubeDx (
openDxObject = postGroupDxObject,
filename = cavitiesTubeObject.getFilename(),
proteinObject= cavitiesTubeObject.getProteinObject(),
waterObject= cavitiesTubeObject.getWaterObject(),
scanMethod = cavitiesTubeObject.getScanMethod(),
scanned=cavitiesTubeObject.getScanned(),
grouped='Yes',
groupes=None,
VoxelGroupGrid = None,
minDiameter = cavitiesTubeObject.getMinDiameter(),
protThreshold = cavitiesTubeObject.getProtThreshold(),
solventThreshold =cavitiesTubeObject.getSolventThreshold(),
version = version,
protFile =cavitiesTubeObject.getProtFile(),
solvFile = cavitiesTubeObject.getSolvFile(),
filterApplied = cavitiesTubeObject.getFilterApplied(),
)
'''
## tested ! until here ....
postGroupTubeDx = postGroup.postGroup_Neighbor(threshold =int(args.threshold), cavityID = args.cid, edgeLength = int(args.cubicsize) ,distCutoff =int(args.distcutoff))
writePDB = WritePDB (postGroupTubeDx)
#writePDB.write(filename= "2"+args.opdb)
writePDB.writeGroups(groupArray= postGroupTubeDx.getGroupes(), filename= args.opdb)
print "Done"