Skip to content

Commit

Permalink
Add user specified seed for random sampling of training regions
Browse files Browse the repository at this point in the history
  • Loading branch information
evantarbell committed Aug 29, 2019
1 parent 892f410 commit ab2bcdc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/HMMR_ATAC/ArgParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class ArgParser {
private String version;
private int maxTrain=1000;
private boolean rmDup=true;
private boolean printExclude=false;
private boolean printTrain=true;
private long randomTrainSeed = 10151;

/**
* Main constructor
Expand All @@ -65,6 +68,23 @@ public ArgParser(String[] a,String ver){
version = ver;
set();
}
/**
* Access the seed used for random sampling of training regions
* @return a long to represent the seed for random sampling of training regions
*/
public long getRandomTrainSeed(){return randomTrainSeed;}
/**
* Access whether to print the excluded sites
* @return a boolean to determine whether to print excluded sites to output file
*/
public boolean getPrintExclude(){return printExclude;}

/**
* Access whether to print the training sites
* @return a boolean to determine whether to print training sites to output file
*/
public boolean getPrintTrain(){return printTrain;}

/**
* Access whether to remove duplicate reads
* @return a boolean to determine whether to exclude duplicate reads from analysis
Expand Down Expand Up @@ -405,6 +425,22 @@ private void set(){
else{printHMMRTracks=false;}
i++;
break;
case"printExclude":
String TEMPX_print = args[i+1].toLowerCase();
if (TEMPX_print.contains("t")){
printExclude=true;
}
else{printExclude=false;}
i++;
break;
case"printTrain":
String TEMPY_print = args[i+1].toLowerCase();
if (TEMPY_print.contains("t")){
printTrain=true;
}
else{printTrain=false;}
i++;
break;
case"removeDuplicates":
String TEMP1_print = args[i+1].toLowerCase();
if (TEMP1_print.contains("t")){
Expand All @@ -425,6 +461,10 @@ private void set(){
maxTrain=Integer.parseInt(args[i+1]);
i++;
break;
case"randomSeed":
randomTrainSeed=Long.parseLong(args[i+1]);
i++;
break;
case"help":
printUsage();
//System.exit(0);
Expand Down Expand Up @@ -468,6 +508,9 @@ public void printUsage(){
System.out.println("\t--maxTrain <int> Maximum number of training regions to use. Default == 1000");
// System.out.println("\t--printTracks <true || false> Whether or not to print the decomposed HMMRATAC signal tracks. Tracks will be labeled as Output_NFR.bedgraph, Output_Mono.bedgraph etc. Default = false");
System.out.println("\t--removeDuplicates <true || false> Whether or not to remove duplicate reads from analysis. Default = true");
System.out.println("\t--printExclude <true || false> Whether to output excluded regions into Output_exclude.bed. Default = false");
System.out.println("\t--printTrain <true || false> Whether to output training regions into Output_training.bed. Default = true");
System.out.println("\t--randomSeed <long> Seed to set for random sampling of training regions. Default is 10151");
System.out.println("\t-h , --help Print this help message and exit.");
System.exit(0);
}
Expand Down
4 changes: 3 additions & 1 deletion src/HMMR_ATAC/Main_HMMR_Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class Main_HMMR_Driver {
private static boolean rmDup = true;
private static boolean printExclude = false;
private static boolean printTrain = true;
private static long randomTrainSeed=10151;

private static String trainingRegions;

Expand Down Expand Up @@ -127,6 +128,7 @@ public static void main(String[] args) throws IOException {
rmDup = p.getRemoveDuplicates();
printExclude = p.getPrintExclude();
printTrain = p.getPrintTrain();
randomTrainSeed = p.getRandomTrainSeed();
// printHMMRTracks = p.getPrintHMMRTracks();
//For run time calculation
Long startTime = System.currentTimeMillis();
Expand Down Expand Up @@ -292,7 +294,7 @@ public static void main(String[] args) throws IOException {
// }

//Shuffle training list before choosing.
Collections.shuffle(train, new Random(3));
Collections.shuffle(train, new Random(randomTrainSeed));
for (int i = 0;i < maxTrain;i++){
newTrain.add(train.get(i));
}
Expand Down

0 comments on commit ab2bcdc

Please sign in to comment.