Skip to content

Commit

Permalink
add seed support (seedForRandom) in java
Browse files Browse the repository at this point in the history
  • Loading branch information
egeulgen committed May 5, 2023
1 parent 8cbac07 commit a6a548a
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 12 deletions.
Binary file modified inst/java/ActiveSubnetworkSearch.jar
Binary file not shown.
Empty file.
Empty file modified java/ActiveSubnetworkSearchAlgorithms/GAIndividual.java
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion java/ActiveSubnetworkSearchAlgorithms/GeneticAlgorithm.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ArrayList<Subnetwork> geneticAlgorithm(){
networkNodeList = ActiveSubnetworkSearch.networkNodeList;
populationSize=Parameters.ga_populationSize;
ArrayList<GAIndividual> population=new ArrayList<>();
random=new Random();
random=new Random(Parameters.seedForRandom);

initializePopulation(population, populationSize);

Expand Down
Empty file modified java/ActiveSubnetworkSearchAlgorithms/GreedySearch.java
100644 → 100755
Empty file.
9 changes: 6 additions & 3 deletions java/ActiveSubnetworkSearchAlgorithms/SimulatedAnnealing.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public class SimulatedAnnealing {
* @param scoreCalculations
*/
public ArrayList<Subnetwork> simulatedAnnealing() {


Random rand = new Random(Parameters.seedForRandom);


Network network=ActiveSubnetworkSearch.network;
ScoreCalculations scoreCalculations=ActiveSubnetworkSearch.scoreCalculations;

Expand All @@ -51,7 +54,7 @@ public ArrayList<Subnetwork> simulatedAnnealing() {
}
}else{
for (Node node : nodesOffSet) {
if(Math.random()<Parameters.geneInitialAdditionProbability){
if(rand.nextDouble()<Parameters.geneInitialAdditionProbability){
nodesOnSet.add(node);
}
}
Expand All @@ -78,7 +81,7 @@ public ArrayList<Subnetwork> simulatedAnnealing() {

double T = initialTemperature;
double temp_step = 1 - Math.pow((finalTemperature / initialTemperature), (1.0 / totalIterations));
Random rand = new Random();


System.out.println("Percentage of finished job, node number and score of modules that have more than one node are as follows:");
int percent=0;
Expand Down
Empty file modified java/ActiveSubnetworkSearchMisc/Gaussian.java
100644 → 100755
Empty file.
10 changes: 7 additions & 3 deletions java/ActiveSubnetworkSearchMisc/ScoreCalculations.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.HashMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.Collections;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -128,15 +129,18 @@ private void calculateMeanAndStdForMonteCarlo() {
}
// System.out.println(""+significantNodesList.size()+" "+nonsignificantNodesList.size());

Random random=new Random(Parameters.seedForRandom);


for (int trial = 0; trial < numberOfTrials; trial++) {
// long start=System.nanoTime();

Collections.shuffle(nodeListForSampling);
Collections.shuffle(nodeListForSampling, random);

//These code can be used to first add significant nodes and start
//sampling with positive scored nodes
// Collections.shuffle(significantNodesList);
// Collections.shuffle(nonsignificantNodesList);
// Collections.shuffle(significantNodesList, random);
// Collections.shuffle(nonsignificantNodesList, random);
// nodeListForSampling.clear();
// nodeListForSampling.addAll(significantNodesList);
// nodeListForSampling.addAll(nonsignificantNodesList);
Expand Down
Empty file modified java/ActiveSubnetworkSearchMisc/Subnetwork.java
100644 → 100755
Empty file.
Empty file modified java/ActiveSubnetworkSearchMisc/ZStatistics.java
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions java/Application/AppActiveSubnetworkSearch.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public static void main(String[] args) {

public static void processArguments(String[] args) throws Exception {
String helpText;
helpText = "It is recommended to increase Stack size while running. You can use\n"
+ "java -Xss4m -jar ActiveSubnetworkSearch.jar\n"
+ "Options of the application are\n"
helpText = "Options of the application are\n"
+ "-sif=<path> \tuses the given interaction file\n"
+ "-sig=<path> \tuses the given experiment file (gene p-value pairs)\n"
+ "-method=[GR|SA|GA] \truns greedy search, simulated annealing or genetic algorithm for the search (default GR)\n"
Expand All @@ -46,7 +44,8 @@ public static void processArguments(String[] args) throws Exception {
+ "-grMaxDepth=<value> \tsets max depth in greedy search, 0 for no limit (default 1)\n"
+ "-grSearchDepth=<value> \tsets search depth in greedy search (default 1)\n"
+ "-grOverlap=<value> \tsets overlap threshold for results of greedy search (default 0.5)\n"
+ "-grSubNum=<value> \tsets number of subnetworks to be presented in the results (default 1000)\n";
+ "-grSubNum=<value> \tsets number of subnetworks to be presented in the results (default 1000)\n"
+ "-seedForRandom=<value> \tsets the seed for random number generators, useful for reproducibility (default 1234)\n";
if(args.length==0 || args[0].equals("-h") || args[0].equals("help") || args[0].equals("-help")){
System.out.println(helpText);
}else{
Expand Down Expand Up @@ -78,6 +77,7 @@ public static void processArguments(String[] args) throws Exception {
case "-grSearchDepth":Parameters.gr_searchDepth=Integer.parseInt(value);break;
case "-grOverlap":Parameters.gr_overlapThreshold=Double.parseDouble(value);break;
case "-grSubNum":Parameters.gr_subnetworkNum=Integer.parseInt(value);break;
case "-seedForRandom":Parameters.seedForRandom=Integer.parseInt(value);break;
default:System.out.println("Unknown argument: "+argType);
}
}
Expand Down
3 changes: 2 additions & 1 deletion java/Application/Parameters.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @author Ozan Ozisik
*/


public class Parameters {
public static String sifPath="BIOGRID-ORGANISM-Homo_sapiens-3.4.155.OzCleaned.sif";
public static String experimentFilePath="Behcet_jp_GWASPvalue.txt";
Expand Down Expand Up @@ -36,4 +35,6 @@ public enum SearchMethod{GR, SA, GA};
public static double gr_overlapThreshold=0.5;//(default 0.5)
public static double gr_subnetworkNum=1000;//(default 1000)

public static int seedForRandom=1234;

}
Empty file modified java/File/ExperimentFileReader.java
100644 → 100755
Empty file.
Empty file modified java/File/SIFReader.java
100644 → 100755
Empty file.
Empty file modified java/Network/Network.java
100644 → 100755
Empty file.
Empty file modified java/Network/Node.java
100644 → 100755
Empty file.
Empty file modified java/Network/SubnetworkFinder.java
100644 → 100755
Empty file.

0 comments on commit a6a548a

Please sign in to comment.