@@ -29,6 +29,8 @@ my $SHORTESTDISTANCE = "shortest";
2929my $AVERAGEDISTANCE = " average" ;
3030my $INDEPENDENT = " independent" ;
3131my $DEPENDENT = " dependent" ;
32+ my $LOCAL = " local" ;
33+ my $NONE = " none" ;
3234
3335sub new {
3436 my $class = shift ;
@@ -86,13 +88,45 @@ sub process {
8688
8789 # ####################################################
8890
89- my $pairwiseFN = " $this ->{'distance_measure'}.$this ->{pairwise_file_name_only}" ;
90-
9191 # print "distance matrix\n";
9292 # print Dumper $distance_matrix;
9393 # print "mutations\n";
9494 # print Dumper $mutations;
9595
96+ $this -> densityClustering( $mutations , $distance_matrix );
97+
98+ my $numStructure = scalar keys %{ $distance_matrix };
99+ print " Density-based clusters are being calculated for $numStructure structures.\n\n " ;
100+
101+ }
102+
103+ # ####
104+ # Functions
105+ # ####
106+
107+ sub densityClustering {
108+ my ( $this , $mutations , $distance_matrix ) = @_ ;
109+
110+ print STDOUT " HotSpot3D::Cluster::Density::densityClustering\n " ;
111+
112+ if ( $this -> {' parallel' } eq $LOCAL ) {
113+ $this -> localParallelDensityClustering( $mutations , $distance_matrix );
114+ # } elsif ( $this->{'parallel'} eq $BSUB ) {
115+ # $this->bsubParallelNetworkClustering( $clusterings , $mutations , $distance_matrix );
116+ } else {
117+ $this -> noParallelDensityClustering( $mutations , $distance_matrix );
118+ }
119+ return ;
120+ }
121+
122+ sub localParallelDensityClustering {
123+ my ( $this , $mutations , $distance_matrix ) = @_ ;
124+
125+ my $pairwiseFN = " $this ->{'distance_measure'}.$this ->{pairwise_file_name_only}" ;
126+ print STDOUT " \t Parallel clustering over structures with up to " .$this -> {' max_processes' }." processes\n " ;
127+ my $pm = Parallel::ForkManager-> new( $this -> {' max_processes' } );
128+
129+ DATA_LOOP:
96130 foreach my $structure ( keys %{$distance_matrix } ) { # run the density calculation for each available structure
97131 # print "Structure= $structure\n";
98132 # name output files as *.$pdbID.structure.*
@@ -105,21 +139,41 @@ sub process {
105139 $this -> MainOPTICS( $structure , $distance_matrix , $mutations ); # perform OPTICS for the first time
106140 $this -> RunSuperClustersID(); # perform Clustering for the reference run
107141
108- print " Reference run: Done.\n Start probability calculation\n " ;
142+ print " Reference run: Done.\n Start probability calculation for $structure \n " ;
109143
110144 $this -> getClusterProbabilities( $structure , $distance_matrix , $mutations ); # perform cluster-membership probability calculation
111145
112- print " \n Probability Calculation is Done.\n\n " ;
146+ print " \n Probability Calculation is Done for $structure .\n\n " ;
113147 }
148+ $pm -> wait_all_children;
114149
115- my $numStructure = scalar keys %{ $distance_matrix };
116- print " Density-based clusters are being calculated for $numStructure structures.\n\n " ;
117-
150+ return ;
118151}
119152
120- # ####
121- # Functions
122- # ####
153+ sub noParallelDensityClustering {
154+ my ( $this , $mutations , $distance_matrix ) = @_ ;
155+ print " Serially clustering over structures\n " ;
156+
157+ my $pairwiseFN = " $this ->{'distance_measure'}.$this ->{pairwise_file_name_only}" ;
158+ foreach my $structure ( keys %{$distance_matrix } ) { # run the density calculation for each available structure
159+ # print "Structure= $structure\n";
160+ # name output files as *.$pdbID.structure.*
161+ $this -> {pairwise_file_name_only } = " $structure .Structure.$pairwiseFN " ;
162+
163+ # call the SetOfNodes hash for each structure
164+ $this -> {" CurrentSetOfNodes" } = $distance_matrix -> {$structure };
165+
166+ # ##### Reference run: start
167+ $this -> MainOPTICS( $structure , $distance_matrix , $mutations ); # perform OPTICS for the first time
168+ $this -> RunSuperClustersID(); # perform Clustering for the reference run
169+
170+ print " Reference run: Done.\n Start probability calculation for $structure \n " ;
171+
172+ $this -> getClusterProbabilities( $structure , $distance_matrix , $mutations ); # perform cluster-membership probability calculation
173+
174+ print " \n Probability Calculation is Done for $structure .\n\n " ;
175+ }
176+ }
123177
124178sub MainOPTICS {
125179 my $this = shift ;
0 commit comments