-
Notifications
You must be signed in to change notification settings - Fork 1
/
Server.cpp
2818 lines (2409 loc) · 78 KB
/
Server.cpp
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****************************************************************************/
/* ______________________ */
/* / _ _ _ _ _ _ _ _ _ _ _) */
/* ____ ____ _ / /__ __ _____ __ */
/* (_ _)( ___)( \/ /( \/ )( _ )( ) */
/* )( )__) ) ( ) ( )(_)( )(__ */
/* (__) (____)/ /\_)(_/\/\_)(_____)(____) */
/* _ _ _ _ __/ / */
/* (___________/ ___ ___ */
/* \ )| | ) _ _|\ ) */
/* --- \/ | | / |___| \_/ */
/* _/ */
/* */
/* Copyright (C) The University of Texas at Austin */
/* */
/* Author: Vinay Siddavanahalli <[email protected]> 2004-2005 */
/* */
/* Principal Investigator: Chandrajit Bajaj <[email protected]> */
/* */
/* Professor of Computer Sciences, */
/* Computational and Applied Mathematics Chair in Visualization, */
/* Director, Computational Visualization Center (CVC), */
/* Institute of Computational Engineering and Sciences (ICES) */
/* The University of Texas at Austin, */
/* 201 East 24th Street, ACES 2.324A, */
/* 1 University Station, C0200 */
/* Austin, TX 78712-0027 */
/* http://www.cs.utexas.edu/~bajaj */
/* */
/* http://www.ices.utexas.edu/CVC */
/* This software comes with a license. Using this code implies that you */
/* read, understood and agreed to all the terms and conditions in that */
/* license. */
/* */
/* We request that you agree to acknowledge the use of the software that */
/* results in any published work, including scientific papers, films and */
/* videotapes by citing the reference listed below */
/* */
/* C. Bajaj, P. Djeu, V. Siddavanahalli, A. Thane, */
/* Interactive Visual Exploration of Large Flexible Multi-component */
/* Molecular Complexes, */
/* Proc. of the Annual IEEE Visualization Conference, October 2004, */
/* Austin, Texas, IEEE Computer Society Press, pp. 243-250. */
/* */
/*****************************************************************************/
#include "Server.h"
#include "SurfaceDataManager/SurfaceData.h"
#include "BallAndStickDataManager/BallAndStickDataManager.h"
#include "DockingManager.h"
#include "SimpleVolumeData.h"
#include "moleculevizmainwindow.h"
#include "ColorTable.h"
#include "GroupOfAtoms.h"
#include "Atom.h"
#include "parserPDBtoGOA.h"
#include "GOAFileIO.h"
#include "MultiContour.h"
#include "VolumeDataManager/VolumeData.h"
#include "GeometryLoader.h"
#include "VolumeLoader.h"
#include "GOALoader.h"
#include "SimpleVolumeDataIsocontourer.h"
#include "UsefulMath/LinearAlgebra.h"
#include "BlurMapsDataManager.h"
#include "SurfaceAtomExtractor.h"
#include "SkinRegion2.h"
#include "contour.h"
#include "DownloadPDB.h"
#include "AreaVolume.h"
#include "sdfLib.h"
#include "MolecularCharacteristics.h"
#include "MergeVolumes.h"
#include "MoleculeMorph.h"
#include "DirectToGridSummationModule.h"
#include "GaussianKernel.h"
#include "UniformOutputGrid.h"
#include "Matrix.h"
#include "Vector.h"
#include "Quaternion.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <qfile.h>
#include <qtextstream.h>
extern void getContourSpectrum(unsigned char* uchar_data, int type, int* dim, int array_size, float* isoval , float* area, float* min_vol, float* max_vol, float* gradient, float* span);
Server::Server()
{
}
Server::~Server()
{
}
bool Server::depthColor( int argc, char* argv[] )
{
// Take as input a rawiv file and create a depth colored rawv.
// It needs a color map also. We are currently using a default map
if( argc != 7 )
{
printUsage();
return false;
}
char inputFileName[256];
char outputFileName[256];
int dim1, dim2, dim3;
strcpy( inputFileName, argv[2] );
strcpy( outputFileName, argv[3] );
dim1 = atoi(argv[4]); dim2 = atoi(argv[5]); dim3 = atoi(argv[6]);
int colorMapSize = 256; // new rover supports only 256 - be careful SKVINAY !
double dColorMap[256*4];
int i, j;
for( i=0; i<256; i++ )
{
dColorMap[i*4+0] = 1;
dColorMap[i*4+1] = 0;
dColorMap[i*4+2] = 0;
dColorMap[i*4+3] = 1;
}
double r=1.0, g=1.0, b=1.0;
double oldr = 1.0, oldg = 1.0, oldb = 1.0;
for( i=0; i<8; i++ )
{
for( j=0; j<32; j++ )
{
dColorMap[(i*32 + j)*4 +0] = (r*j/32.0 + oldr*(32-j)/32);
dColorMap[(i*32 + j)*4 +1] = (g*j/32.0 + oldg*(32-j)/32);
dColorMap[(i*32 + j)*4 +2] = (b*j/32.0 + oldb*(32-j)/32);
dColorMap[(i*32 + j)*4 +3] = 1;
}
printf("%d %f %f %f\n", i, r, g, b );
oldr = r; oldg = g; oldb = b;
r = rand()/((double)(RAND_MAX)+1); b = rand()/((double)(RAND_MAX)+1); g = rand()/((double)(RAND_MAX)+1);
}
SimpleVolumeData* simpleVolumeFile = 0;
{
VolumeLoader* volumeLoader = new VolumeLoader();
simpleVolumeFile = volumeLoader->loadFile( inputFileName );
delete volumeLoader;
if( !simpleVolumeFile ) return false;
}
////////////// create depth colored volume ////////////////////
SimpleVolumeData* sData = 0;
sData = simpleVolumeFile->createDepthColoredVolume(dColorMap, colorMapSize-1 );
if( !sData )
{
delete simpleVolumeFile;
return false;
}
////////////////////////////////////////////////////////////////
/////////////// write to file if needed ////////////////////////
bool ret = false;
{
VolumeLoader* volumeLoader = new VolumeLoader();
ret = volumeLoader->saveFile( outputFileName, sData );
delete volumeLoader;
}
/////////////////////////////////////////////////////////////////
delete simpleVolumeFile;
delete sData;
return ret;
}
bool Server::blur( int argc, char* argv[] )
{
// Create a blur map of an input pdb or pqr file. Should we also support pts files ?
// Supports both electron density and hydrophobicity
// Input parameters:
// char* input filename
// char* output filename
// int dim1, dim2, dim3
// double blobby factor
// int density type ( 0 - electron density, 1 - hydrophobicity )
// char* colormap
// int color type ( 0 - , 1 - , 2 - )
// int gap - not very nice to use as it destroys meaning of origin, span etc. Only use sparingly for viz
// Side effects:
// creates RAWIV or RAV5 volume
// Return value:
// bool indicates success or failure of function call
// usage:
// bool getVolume( const char* pdbOrPqrFileName, const char* volFileName,
// int dim1, int dim2, int dim3, int densityType,
// bool writeRawV, double blob, unsigned int color, const char* cmapFile, int gap, int radiusType, unsigned int level );
// radiusType == 0 -> vdv radius, == 1 -> solvent enlarged radius
//
// the 16 to 27 parameters can set to transform the molecule: (cx, cy, cz, nx, ny, nz) old, (cx, cy, cz, nx, ny, nz) new
if( argc != 15 && argc != 27)
{
printUsage();
return false;
}
char inputFileName[256];
char outputFileName[256];
int dim1, dim2, dim3;
PDBParser::GroupOfAtoms::FUNCTIONS densityType;
bool writeRawV;
double blob;
PDBParser::GroupOfAtoms::GOA_TYPE colorLevel;
char cmapFile[256];
int gap;
PDBParser::GroupOfAtoms::RADIUS_TYPE radiusType;
int level;
strcpy( inputFileName, argv[2] );
strcpy( outputFileName, argv[3] );
dim1 = atoi(argv[4]); dim2 = atoi(argv[5]); dim3 = atoi(argv[6]);
if( !PDBParser::GroupOfAtoms::intToFunctionType( &densityType, atoi(argv[7]) ) ) return false;
if( strcmp(argv[8], "true") == 0 )
writeRawV = true;
else if( strcmp(argv[8], "false") == 0 )
writeRawV = false;
else
{
printUsage();
return false;
}
blob = atof(argv[9]);
if( !PDBParser::GroupOfAtoms::intToGOAType( &colorLevel, atoi(argv[10]) ) ) return false;
strcpy( cmapFile, argv[11] );
gap = atoi(argv[12]);
if( !PDBParser::GroupOfAtoms::intToRadiusType( &radiusType, atoi(argv[13]) ) ) return false;
level = atoi(argv[14] );
SimpleVolumeData* sData = 0;
///////////// transform molecule if required////////
if( argc == 27 )
{
CCVOpenGLMath::Matrix transformation;
{
CCVOpenGLMath::Vector old_center(atof(argv[15]), atof(argv[16]), atof(argv[17]), 1);
CCVOpenGLMath::Vector old_normal(atof(argv[18]), atof(argv[19]), atof(argv[20]), 0);
CCVOpenGLMath::Vector new_center(atof(argv[21]), atof(argv[22]), atof(argv[23]), 1);
CCVOpenGLMath::Vector new_normal(atof(argv[24]), atof(argv[25]), atof(argv[26]), 0);
// shift center to new one.
// rotate to align quaternions
// for each mol, we need a predefined center and normal.
// translate mol_center to input_center
// now to rotate:
// cross product gives axis of rotation
// dot product gives the angle
old_normal.normalize();
new_normal.normalize();
CCVOpenGLMath::Vector axis_of_rotation = old_normal.cross( new_normal );
axis_of_rotation.normalize();
double angle_of_rotation = acos(new_normal.dot( old_normal ));
float w = cos( angle_of_rotation / 2.0 );
float x = axis_of_rotation[0] * sin( angle_of_rotation / 2.0 );
float y = axis_of_rotation[1] * sin( angle_of_rotation / 2.0 );
float z = axis_of_rotation[2] * sin( angle_of_rotation / 2.0 );
CCVOpenGLMath::Quaternion quaternion(w, x, y, z);
CCVOpenGLMath::Matrix rotation = quaternion.buildMatrix();
CCVOpenGLMath::Vector tr_old_center = rotation*old_center;
CCVOpenGLMath::Matrix translation = CCVOpenGLMath::Matrix::translation(new_center - tr_old_center);
transformation = rotation.preMultiplication(translation);
//transformation = rotation;
}
sData = BlurMapsDataManager::getVolume( inputFileName, outputFileName,
dim1, dim2, dim3, densityType,
writeRawV, blob, colorLevel, cmapFile, gap, radiusType, level, &transformation);
}
////////////////////////////////////////////////////
else
{
sData = BlurMapsDataManager::getVolume( inputFileName, outputFileName,
dim1, dim2, dim3, densityType,
writeRawV, blob, colorLevel, cmapFile, gap, radiusType, level, 0);
}
bool ret;
if( sData )
ret = true;
else
ret = false;
delete sData;
return ret;
/*{
GOALoader* gLoader = new GOALoader();
PDBParser::GroupOfAtoms* molecule = gLoader->loadFile( argv[2] );
delete gLoader;
if( !molecule ) return false;
int n = 0;
molecule->getNumberOfAtomsRecursive(&n);
if( n <= 0 ) return false;
double blobbiness = atof(argv[9]);
if( blobbiness >= 0 ) return false;
double error = 1e-10;
PDBParser::GroupOfAtoms::FUNCTIONS function = PDBParser::GroupOfAtoms::ELECTRON_DENSITY;
if( !PDBParser::GroupOfAtoms::intToFunctionType( &function, atoi(argv[7]) ) ) return false;
PDBParser::GroupOfAtoms::RADIUS_TYPE radius_type = PDBParser::GroupOfAtoms::VDW_RADIUS;
if( !PDBParser::GroupOfAtoms::intToRadiusType( &radius_type, atoi(argv[13]) ) ) return false;
int GOA_level = atoi(argv[14] );
double min[3]; min[0] = min[1] = min[2] = 1e20;
double max[3]; max[0] = max[1] = max[2] = 1e-20;
double maxRadius = -1;
double* points = new double[n*3];
double* radii = new double[n];
double* weights = new double[n];
molecule->getAttributes( points, radii, min, max, weights, &maxRadius, function, GOA_level, radius_type, n );
CCVSummationModule::Kernel* kernel = new CCVSummationModule::GaussianKernel( blobbiness, error );
unsigned int dimensions[3];
dimensions[0] = atoi(argv[4]); dimensions[1] = atoi(argv[5]); dimensions[2] = atoi(argv[6]);
float* output = new float[dimensions[0]*dimensions[1]*dimensions[2]];
float origin[3]; origin[0] = min[0]; origin[1] = min[1]; origin[2] = min[2];
float span[3];
span[0] = (max[0] - min[0]) / ((double)(dimensions[0]-1));
span[1] = (max[1] - min[1]) / ((double)(dimensions[1]-1));
span[2] = (max[2] - min[2]) / ((double)(dimensions[2]-1));
CCVSummationModule::OutputGrid * outputGrid = new CCVSummationModule::UniformOutputGrid( output, origin, span, dimensions );
CCVSummationModule::SummationModule* summationModule = new CCVSummationModule::DirectToGridSummationModule( points, radii, weights, n, kernel, outputGrid );
if( !summationModule->sum() )
{
if( points ) { delete []points; points = 0; }
if( radii ) { delete []radii; radii = 0; }
if( weights ) { delete []weights; weights = 0; }
if( output ) { delete []output; output = 0; }
return false;
}
{
SimpleVolumeData* vol = new SimpleVolumeData(dimensions);
vol->setDimensions( dimensions );
vol->setNumberOfVariables(1);
vol->setData(0, output);
vol->setType(0, SimpleVolumeData::FLOAT);
vol->setName(0, "TexMols blurring");
float fmin[3], fmax[3];
fmin[0] = min[0]; fmin[1] = min[1]; fmin[2] = min[2];
fmax[0] = max[0]; fmax[1] = max[1]; fmax[2] = max[2];
vol->setMinExtent(fmin);
vol->setMaxExtent(fmax);
VolumeLoader* volumeLoader = new VolumeLoader();
volumeLoader->saveFile("opt.rawiv", vol );
delete volumeLoader;
delete vol;
}
// simpleVolumeData should delete the 'output' data
if( points ) { delete []points; points = 0; }
if( radii ) { delete []radii; radii = 0; }
if( weights ) { delete []weights; weights = 0; }
}
return true;
*/
}
void Server::printUsage()
{
printf("Usage: any one of the following, all corresponding paramters are required. Consult manual for more help\n");
printf("1. MoleculeViz\n");
printf("2. MoleculeViz [-blur <const char* pdbOrPqrFileName> <const char* volFileName> \n<int dim1> <int dim2> <int dim3> <int densityType> \n<bool writeRawV> <double blob> <unsigned int color> <const char* cmapFile> <int gap> <int radiusType> <unsigned int level>]\n");
printf("WRONG , CHANGE 3. MoleculeViz [-setcurvature <int createIsosurface> <const char* inputpdbOrPqrFileName> <int dim1> <int dim2> <int dim3> <double blob> <const char* inputRawSurfaceFileName> <const char* outputMeanRawSurfaceFileName> <const char* outputGaussianRawSurfaceFileName> <const char* outputCurvatureRawSurfaceFileName> <int numberOfGridDivisions> <double maxFunctionError> <int radiusType>]\n");
printf("4. MoleculeViz [-outGridPositions <const char* pdbOrPqrFileName> <unsigned int N1> <unsigned int N2> <unsigned int N3> <double extraSpace>]\n");
printf("5. MoleculeViz [-classifyPoints <const char* inputPtsFileName> <const char* outputPtsFileName> ]\n");
printf("6. MoleculeViz [-growOut <const char* inputRawFileName> <const char* outputRawFileName> <double extent>]\n");
printf("7. MoleculeViz [-getSurfaceFromVolume <const char* volumeFileName> <const char* outputSurfaceFileName> <double isovalue>]\n");
printf("8. MoleculeViz [-getSurfaceFromPDB <const char* pdbOrPqrFileName> <const char* outputSurfaceFileName> <double isovalue> <int dim1> <int dim2> <int dim3> <double blobbiness>]\n");
printf("9. MoleculeViz [-evolve <const char* pdbOrPqrFileName> <const char* changesFile> <const char* pdbOrPqrFileName>]\n");
printf("10. MoleculeViz [-writePDB <const char* inputFileName> <const char* outputFileName> <int outputLevel>]\n");
printf("11. MoleculeViz [-writeGOA <const char* inputFileName> <const char* outputFileName>]\n");
printf("12. MoleculeViz [-depthColor <const char* inputFileName> <const char* outputFileName> <int dim1> <int dim2> <int dim3>]\n");
printf("13. MoleculeViz [-getHydrophobicityOnSurface <const char* inputPDBFileName> <const char* inputSurfaceFileName> <int dim1> <int dim2> <int dim3> <double blobbiness> <const char* outputValuesFileName>]\n");
printf("14. MoleculeViz [-createSkinRegion <const char* inputPDBFileName> <const char* inputSurfaceFileName> <int dim1> <int dim2> <int dim3> <double probeRadius> <int radiusType>]\n");
printf("15. MoleculeViz [-correlate <const char* hydroFile> <const char* meanCurvFile> <const char* gausCurvFile> <double probeRadius> <bool discretizeHydro> <bool discretizeCurv> <double maxDiscreteVal> <double minDiscreteVal> <int rangeToCorrelate = {0->all,<0,>0} >]\n");
printf("16. MoleculeViz [-getArea <const char* surfaceFileName>]\n");
printf("17. MoleculeViz [-getPatchAreas <const char* surfaceFileName> <const char* functionValuesFileName> <double isovalue> <const char* outputFileName>]\n");
printf("18. MoleculeViz [-populateSAS <const char* surfaceFileName> <const char* functionValuesFileName> <double isovalue> <const char* outputFileName>]\n");
printf("19. MoleculeViz [-addVolumes <const char* volume1FileName> <const char* volume2FileName> <const char* volume3FileName> <double scale> <double sum>]\n");
printf("20. MoleculeViz [-convert <const char* inputFileName> <const char* outputFileName>]\n");
printf("21. MoleculeViz [-getSurfaceAtoms <const char* inputFileName> <const char* outputFileName>]\n");
printf("22. MoleculeViz [-getContourStats <const char* inputFileName> <const char* outputFileName>]\n");
printf("23. MoleculeViz [-downloadPDB <const char* pdbID> <const char* outputFileName>]\n");
printf("24. MoleculeViz [-getSignDistanceFunction <const char* inputFileName> <const char* outputFileName> <int size> <int flipNormals>]\n");
printf("25. MoleculeViz [-getMolecularCharacteristics <const char* inputGOAFileName> <const char* elecFileName> <const char* outputFileName> <int numberOfSpheres> opt: <float* active site> <double radius1> .. <double radius_n_of_spheres>]\n" );
printf("26. MoleculeViz [-expandMolecule <const char* inputGOAFileName> <const char* outputGOAFileName>]\n" );
printf("27. MoleculeViz [-mergeGeometry <const char* inputSurfaceFileName1> <const char* inputSurfaceFileName2> <const char* outputSurfaceFileName>]\n" );
printf("28. MoleculeViz [-mergeVolumes <const char* inputSurfaceFileName1> <const char* inputSurfaceFileName2> <const char* outputSurfaceFileName> <optional: original and new center and normals>]\n" );
printf("29. MoleculeViz [-writeTorsionAngles <const char* inputGOAFileName> <const char* outputTorsionAnglesFileName>]\n" );
printf("30. MoleculeViz [-morph <const char* inputGOAFileName1> <const char* inputGOAFileName2> <const char* outputGOAFileNamePrefix> <double resolution> <int maxSteps>]\n" );
printf("31. MoleculeViz [-getElecOnSurface <const char* inputElecVolume> <const char* inputSurfaceFileName> <const char* outputPosSurfaceFileName> <const char* outputNegSurfaceFileName> <const char* outputNeuSurfaceFileName> <double negCutoff> <double posCutoff>]\n" );
printf("32. MoleculeViz [-getCurvaturesOnSurface <const char* inputSurfaceFileName> <const char* outputFileName>]\n");
}
bool Server::execute( int argc, char* argv[], MoleculeVizMainWindow* mWindow )
{
if( argc < 2 ) return false;
if( strcmp(argv[1],"-help") == 0 )
{
printUsage();
return true;
}
if( strcmp(argv[1],"-h") == 0 )
{
printUsage();
return true;
}
if( strcmp(argv[1],"-blur") == 0 )
return blur(argc, argv);
if( strcmp(argv[1],"-setcurvature") == 0 )
return setCurvature(argc, argv);
if( strcmp(argv[1],"-outGridPositions") == 0 )
return outGridPositions(argc, argv);
if( strcmp(argv[1],"-classifyPoints") == 0 )
return classifyPoints(argc, argv);
if( strcmp(argv[1],"-growOut") == 0 )
return growOut(argc, argv);
if( strcmp(argv[1],"-getSurfaceFromVolume") == 0 )
return getSurfaceFromVolume(argc, argv);
if( strcmp(argv[1],"-getSurfaceFromPDB") == 0 )
return getSurfaceFromPDB(argc, argv);
if( strcmp(argv[1],"-evolve") == 0 )
return evolve(argc, argv);
if( strcmp(argv[1],"-writePDB") == 0 )
return writePDB(argc, argv);
if( strcmp(argv[1],"-writeGOA") == 0 )
return writeGOA(argc, argv);
if( strcmp(argv[1],"-depthColor") == 0 )
return depthColor(argc, argv);
if( strcmp(argv[1],"-getMaxDistanceFromPoint") == 0 )
return getMaxDistanceFromPoint(argc, argv);
if( strcmp(argv[1],"-getHydrophobicityOnSurface") == 0 )
return getHydrophobicityOnSurface(argc, argv);
if( strcmp(argv[1],"-createSkinRegion") == 0 )
return createSkinRegion(argc, argv);
if( strcmp(argv[1],"-correlate") == 0 )
return correlate(argc, argv);
if( strcmp(argv[1],"-getArea") == 0 )
return getArea(argc, argv);
if( strcmp(argv[1],"-getPatchAreas") == 0 )
return getPatchAreas(argc, argv);
if( strcmp(argv[1],"-populateSAS") == 0 )
return populateSAS(argc, argv);
if( strcmp(argv[1],"-addVolumes") == 0 )
return addVolumes(argc, argv);
if( strcmp(argv[1],"-convert") == 0 )
return convert(argc, argv);
if( strcmp(argv[1],"-getSurfaceAtoms") == 0 )
return getSurfaceAtoms(argc, argv);
if( strcmp(argv[1],"-getContourStats") == 0 )
return getContourStats(argc, argv);
if( strcmp(argv[1],"-getSignDistanceFunction") == 0 )
return getSignDistanceFunction(argc, argv);
if( strcmp(argv[1],"-getMolecularCharacteristics") == 0 )
return getMolecularCharacteristics(argc, argv);
if( strcmp(argv[1],"-expandMolecule") == 0 )
return expandMolecule(argc, argv);
if( strcmp(argv[1],"-mergeGeometry") == 0 )
return mergeGeometry(argc, argv);
if( strcmp(argv[1],"-mergeVolumes") == 0 )
return mergeVolumes(argc, argv);
if( strcmp(argv[1],"-writeTorsionAngles") == 0 )
return writeTorsionAngles(argc, argv);
if( strcmp(argv[1],"-morph") == 0 )
return morph(argc, argv);
if( strcmp(argv[1],"-getElecOnSurface") == 0 )
return getElecOnSurface(argc, argv);
if( strcmp(argv[1],"-getCurvaturesOnSurface") == 0 )
return getCurvaturesOnSurface(argc, argv);
if( strcmp(argv[1],"-addData") == 0 )
return addNewDataSet( argc, argv, mWindow );
if( strcmp(argv[1],"-splitView") == 0 )
return splitView( argc, argv, mWindow );
if( strcmp(argv[1],"-deleteData") == 0 )
return deleteData( argc, argv, mWindow );
if( strcmp(argv[1],"-deletePrevData") == 0 )
return deletePrevData( argc, argv, mWindow );
if( strcmp(argv[1],"-deleteAllData") == 0 )
return deleteAllData( argc, argv, mWindow );
if( strcmp(argv[1],"-setVisible") == 0 )
return setVisible( argc, argv, mWindow );
if( strcmp(argv[1],"-setVisiblePrev") == 0 )
return setVisiblePrev( argc, argv, mWindow );
if( strcmp(argv[1],"-saveImage") == 0 )
return saveImage( argc, argv, mWindow );
if( strcmp(argv[1],"-setGridVisible") == 0 )
return setGridVisible( argc, argv, mWindow );
if( strcmp(argv[1],"-downloadPDB") == 0 )
return downloadPDB(argc, argv, mWindow);
return false;
}
bool Server::outGridPositions( int argc, char* argv[] )
{
if( argc != 7 )
{
printUsage();
return false;
}
char pdbOrPqrFileName[256];
unsigned int N1;
unsigned int N2;
unsigned int N3;
double extraSpace;
strcpy( pdbOrPqrFileName, argv[2] );
N1 = atoi(argv[3]); N2 = atoi(argv[4]); N3 = atoi(argv[5]);
extraSpace = atof( argv[6] );
DockingManager::outGridPositionsInt( pdbOrPqrFileName, NULL, N1, N2, N3, extraSpace );
//DockingManager::outGridPositions( pdbOrPqrFileName, N1, N2, N3, extraSpace );
return true;
}
bool Server::getSurfaceFromVolume( int argc, char* argv[] )
{
if( argc != 5 )
{
printUsage();
return false;
}
char volumeFileName[256];
char surfaceFileName[256];
double isovalue = 1;
strcpy( volumeFileName, argv[2] );
strcpy( surfaceFileName, argv[3] );
isovalue = atof( argv[4] );
///////// read in the volume ////////////////////
SimpleVolumeData* sData = 0;
{
VolumeLoader* vLoader = new VolumeLoader();
sData = vLoader->loadFile( volumeFileName );
delete vLoader;
if( !sData )return false;
}
/////////////////////////////////////////////////
Geometry* geometry = SimpleVolumeDataIsocontourer::getIsocontour(sData, isovalue);
if( geometry == 0 )
{
delete sData;
return false;
}
///////////////////////////////////////////////////
///////// save the isocontour /////////////////////
GeometryLoader* geometryLoader = new GeometryLoader();
if( !geometryLoader->saveFile( surfaceFileName, "Rawnc files (*.rawnc)", geometry) )
{
delete geometry;
delete sData;
return false;
}
delete geometryLoader;
///////////////////////////////////////////////////
delete geometry;
delete sData;
return true;
}
bool Server::evolve( int argc, char* argv[] )
{
if( argc != 5 )
{
printUsage();
return false;
}
char pdbOrPqrFileName[256];
char changesFile[256];
char outputPdbOrPqrFileName[256];
strcpy( pdbOrPqrFileName, argv[2] );
strcpy( changesFile, argv[3] );
strcpy( outputPdbOrPqrFileName, argv[4] );
BallAndStickDataManager b;
b.evolve( pdbOrPqrFileName, changesFile, outputPdbOrPqrFileName );
return true;
}
bool Server::setCurvature( int argc, char* argv[] )
{
if( argc < 3 )
{
printUsage();
return false;
}
char inputPQRorPDBFileName[256];
char inputRawSurfaceFileName[256];
char outputMeanRawSurfaceFileName[256];
char outputGaussianRawSurfaceFileName[256];
char outputVolumeFileName[256];
char curvatureFileName[256];
int dim1, dim2, dim3;
double blob, isovalue;
int createIsosurface;
int numberOfGridDivisions;
double maxFunctionError;
PDBParser::GroupOfAtoms::RADIUS_TYPE radiusType;
int level;
createIsosurface = atoi(argv[2]);
if( createIsosurface == 0 )
{
if( argc != 16 )
{
printUsage();
return false;
}
strcpy( inputPQRorPDBFileName, argv[3] );
strcpy( inputRawSurfaceFileName, argv[4] );
strcpy( outputMeanRawSurfaceFileName, argv[5] );
strcpy( outputGaussianRawSurfaceFileName, argv[6] );
strcpy( curvatureFileName, argv[7] );
dim1 = atoi(argv[8]); dim2 = atoi(argv[9]); dim3 = atoi(argv[10]);
blob = atof(argv[11]);
numberOfGridDivisions = atoi( argv[12] );
maxFunctionError = atof( argv[13] );
if( !PDBParser::GroupOfAtoms::intToRadiusType( &radiusType, atoi(argv[14]) ) ) return false;
level = atoi(argv[15]);
return BlurMapsDataManager::getCurvaturesFromIsocontourFile( inputPQRorPDBFileName,
dim1, dim2, dim3, blob, inputRawSurfaceFileName,
outputMeanRawSurfaceFileName, outputGaussianRawSurfaceFileName,
curvatureFileName,
numberOfGridDivisions, maxFunctionError, radiusType, level );
}
//// new with isovalue
else if( createIsosurface == 1 )
{
if( argc != 16 )
{
printUsage();
return false;
}
strcpy( inputPQRorPDBFileName, argv[3] );
strcpy( outputMeanRawSurfaceFileName, argv[4] );
strcpy( outputGaussianRawSurfaceFileName, argv[5] );
strcpy( curvatureFileName, argv[6] );
dim1 = atoi(argv[7]); dim2 = atoi(argv[8]); dim3 = atoi(argv[9]);
blob = atof(argv[10]);
isovalue = atof(argv[11]);
numberOfGridDivisions = atoi( argv[12] );
maxFunctionError = atof( argv[13] );
if( !PDBParser::GroupOfAtoms::intToRadiusType( &radiusType, atoi(argv[14]) ) ) return false;
level = atoi(argv[15]);
SimpleVolumeData* sData = 0;
///////// create volume from blurring code ////////////
sData = BlurMapsDataManager::getVolume( inputPQRorPDBFileName,
outputVolumeFileName,
dim1, dim2, dim3, PDBParser::GroupOfAtoms::ELECTRON_DENSITY,
false, blob, PDBParser::GroupOfAtoms::ATOM, NULL, 0, radiusType, level );
if( !sData ) return false;
////////////////////////////////////////////////////////
////// extract an isocontour //////////////////
Geometry* geometry = SimpleVolumeDataIsocontourer::getIsocontour(sData, isovalue);
if( geometry == 0 ) return false;
/////////////////////////////////////////////
///// get curvatures //////////////
return BlurMapsDataManager::getCurvatures( inputPQRorPDBFileName, dim1, dim2, dim3,
blob, geometry, outputMeanRawSurfaceFileName,
outputGaussianRawSurfaceFileName, curvatureFileName,
numberOfGridDivisions, maxFunctionError, radiusType, level );
////////////////////////////////////
return false;
}
else
{
printUsage();
return false;
}
}
//SKVINAY
bool Server::classifyPoints( int argc, char* argv[] )
{
if( argc != 3 )
{
printUsage();
return false;
}
char inputPtsFile[256];
char outputPtsFile[256];
strcpy( inputPtsFile, argv[2] );
strcpy( outputPtsFile, argv[3] );
bool ret = false;
/* VorocompDataManager *v = new VorocompDataManager();
ret = v->classifyPoints( inputPtsFile, outputPtsFile );
delete v;
*/
return ret;
}
bool Server::growOut( int argc, char* argv[] )
{
if( argc != 5 )
{
printUsage();
return false;
}
char fileNameIn[256];
char fileNameOut[256];
double extent;
strcpy( fileNameIn, argv[2] );
strcpy( fileNameOut, argv[3] );
extent = atof(argv[4]);
DockingManager::growOut( fileNameIn, fileNameOut, extent );
return false;
}
bool Server::writePDB( int argc, char* argv[] )
{
if( argc != 5 )
{
printUsage();
return false;
}
int outputLevel = atoi(argv[4]);
///////// create the molecule //////////
GOALoader* gLoader = new GOALoader();
PDBParser::GroupOfAtoms* molecule = gLoader->loadFile( argv[2] );
delete gLoader;
if( !molecule ) return false;
////////////////////////////////////////
///////// write the output ///////////////
FILE* stream = fopen( argv[3], "w" );
if( stream == 0 )
{
delete molecule; molecule= 0;
return false;
}
bool ret = PDBParser::writeGOA2PDB ( stream, molecule, outputLevel, 0);
fclose( stream );
//////////////////////////////////////////
delete molecule; molecule = 0;
return ret;
}
bool Server::writeGOA( int argc, char* argv[] )
{
if( argc != 4 )
{
printUsage();
return false;
}
///////// create the molecule //////////
GOALoader* gLoader = new GOALoader();
PDBParser::GroupOfAtoms* molecule = gLoader->loadFile( argv[2] );
delete gLoader;
if( !molecule ) return false;
////////////////////////////////////////
///////// write the output ///////////////
FILE* stream = fopen( argv[3], "w" );
if( stream == 0 )
{
delete molecule; molecule= 0;
return false;
}
bool ret = PDBParser::writeGOAtoFile ( stream, molecule);
fclose( stream );
//////////////////////////////////////////
delete molecule; molecule = 0;
return ret;
}
bool Server::addNewDataSet( int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 3 ) return false;
char inputFileName[256];
strcpy( inputFileName, argv[2] );
return mWindow->addNewDataSet( inputFileName);
}
bool Server::splitView(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 2 ) return false;
mWindow->splitViewSlot();
return true;
}
bool Server::deleteData(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 3 ) return false;
int dataSetIndex = atoi(argv[2]);
mWindow->deleteData( dataSetIndex );
return true;
}
bool Server::deletePrevData(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 2 ) return false;
return mWindow->deletePrevData();
}
bool Server::deleteAllData(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 2 ) return false;
return mWindow->deleteAllData();
}
bool Server::setVisible(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 4 ) return false;
bool render;
char renderC[256];
strcpy( renderC, argv[2] );
#ifdef _WIN32
if( strcmpi( renderC, "true" ) == 0 )
#else
if( strcasecmp( renderC, "true" ) == 0 )
#endif
render = true;
else
render = false;
int dataSetIndex = atoi(argv[3]);
return mWindow->setVisible(render, dataSetIndex);
}
bool Server::setVisiblePrev(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 3 ) return false;
bool render;
char renderC[256];
strcpy( renderC, argv[2] );
#ifdef _WIN32
if( strcmpi( renderC, "true" ) == 0 )
#else
if( strcasecmp( renderC, "true" ) == 0 )
#endif
render = true;
else
render = false;
return mWindow->setVisiblePrev(render);
}
bool Server::saveImage(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 4 ) return false;
return mWindow->saveImage(argv[2], argv[3]);
}
bool Server::printPDBInformation( int argc, char* argv[] )
{
if( argc != 5 ) return false;
BallAndStickDataManager b;
int printType = atoi(argv[4]);
return b.printPDBInformation( argv[2], argv[3], printType ); // input , output file names
}
bool Server::setGridVisible(int argc, char* argv[], MoleculeVizMainWindow *mWindow )
{
if( !mWindow ) return false;
if( argc != 3 ) return false;
#ifdef _WIN32
if( strcmpi( argv[2], "true" ) == 0 )
#else
if( strcasecmp( argv[2], "true" ) == 0 )
#endif
return mWindow->setGridVisible(true);
else
return mWindow->setGridVisible(false);
}
bool Server::getMaxDistanceFromPoint( int argc, char* argv[] )
{
if( argc != 8 ) return false;
double xOrigin = 0, yOrigin = 0, zOrigin = 0;
bool appendToFile = true;
// argv[2], argv[3] = input , output file names
xOrigin = atof( argv[4] );
yOrigin = atof( argv[5] );
zOrigin = atof( argv[6] );
BallAndStickDataManager b;
#ifdef _WIN32
if( strcmpi( argv[7], "true" ) == 0 )
#else
if( strcasecmp( argv[7], "true" ) == 0 )
#endif
return b.getMaxDistanceFromPoint( argv[2], argv[3], xOrigin, yOrigin, zOrigin, true );
else
return b.getMaxDistanceFromPoint( argv[2], argv[3], xOrigin, yOrigin, zOrigin, false );
}
bool Server::getHydrophobicityOnSurface( int argc, char* argv[] )
{
if( argc != 11 ) return false;
char inputPDBFile[256];
char inputSurfaceFile[256];
int dim1,dim2,dim3;
double blobbiness;
char outputHydrophobicityValues[256];
PDBParser::GroupOfAtoms::RADIUS_TYPE radiusType;
int level;
strcpy( inputPDBFile, argv[2] );
strcpy( inputSurfaceFile, argv[3] );
dim1 = atoi(argv[4]); dim2 = atoi(argv[5]); dim3 = atoi(argv[6]);
blobbiness = atof(argv[7]);
strcpy( outputHydrophobicityValues, argv[8] );
if( !PDBParser::GroupOfAtoms::intToRadiusType( &radiusType, atoi(argv[9]) ) ) return false;
level = atoi(argv[10]);
/////// make the hydrophobicity volume //////
SimpleVolumeData* sData = 0;