@@ -97,6 +97,7 @@ public class Main_DBBUILD_3 {
9797 * @param keepRatio
9898 * @param doGapJumps
9999 * @param limitTo1Jump
100+ * @param gapJumpThreshold
100101 * @throws java.io.FileNotFoundException
101102 * @throws java.lang.ClassNotFoundException
102103 */
@@ -127,15 +128,10 @@ public static void DBGeneration( int analysisType,
127128 int keepAtMost ,
128129 float keepRatio ,
129130 boolean doGapJumps ,
130- boolean limitTo1Jump
131+ boolean limitTo1Jump ,
132+ float gapJumpThreshold
131133 ) throws FileNotFoundException , IOException , ClassNotFoundException {
132134
133-
134-
135-
136-
137-
138-
139135
140136 ////////////////////////////////////////////////////////////////////
141137 ////////////////////////////////////////////////////////////////////
@@ -232,6 +228,26 @@ public static void DBGeneration( int analysisType,
232228 }
233229 align .writeAlignmentAsFasta (reducedAlign );
234230 Infos .println ("Reduced alignment written to: " +reducedAlign .getAbsolutePath ());
231+
232+ }
233+
234+ //check gap ratio in reference alignment
235+ //if >= to gapJumpThreshold, activate gap jumps
236+ boolean gapJumpsActivated =false ;
237+ if (doGapJumps ) { //if false, the user explicitely deactivated jumps
238+
239+ double [] gapProportions = align .getGapProportions ();
240+ double gap =0.0 ; double nonGap =0.0 ;
241+ for (int i = 0 ; i < gapProportions .length ; i ++) {
242+ gap +=gapProportions [i ];
243+ nonGap +=(1.0 -gapProportions [i ]);
244+ }
245+ double gapRatio =gap /nonGap ;
246+ Infos .println ("Gap ratio: " +gapRatio );
247+ if (gapRatio >=gapJumpThreshold ) {
248+ gapJumpsActivated =true ;
249+ Infos .println (">=" +gapJumpThreshold +", gap jumps activated." );
250+ }
235251 }
236252
237253
@@ -411,11 +427,11 @@ public static void DBGeneration( int analysisType,
411427 // and the modification in ARTree operated by the AR software
412428 // (which renames internal nodes/labels in its own way...)
413429 System .out .println ("Parsing Ancestral reconstruction results..." );
414- arpr =new ARResults ( arpl ,
415- align ,
416- originalTree ,
417- extendedTree ,
418- s
430+ arpr =new ARResults ( arpl ,
431+ align ,
432+ originalTree ,
433+ extendedTree ,
434+ s
419435 );
420436 //output in the AR directory the mapping of the nodes for debugging
421437 File map =new File (arpl .ARPath .getAbsolutePath ()+File .separator +"ARtree_id_mapping.tsv" );
@@ -629,7 +645,7 @@ public static void DBGeneration( int analysisType,
629645 pos ,
630646 nodeId ,
631647 wordCompression ,
632- doGapJumps ,
648+ gapJumpsActivated ,
633649 limitTo1Jump
634650 );
635651
@@ -764,7 +780,7 @@ public static void DBGeneration( int analysisType,
764780 File dbmedium =new File (db .getAbsoluteFile ()+".medium" );
765781 File dbsmall =new File (db .getAbsoluteFile ()+".small" );
766782 File dbunion =new File (db .getAbsoluteFile ()+".union" );
767- File dbsmallunion =new File (db .getAbsoluteFile ()+".sunion" );
783+ // File dbsmallunion=new File(db.getAbsoluteFile()+".sunion");
768784
769785
770786
@@ -868,18 +884,18 @@ public static void DBGeneration( int analysisType,
868884 placer .doPlacements (query , dbunion , workDir , callString , nsBound ,keepAtMost ,keepRatio );
869885 }
870886 //reduction to small DB
871- System .out .println ("Reduction to small union DB..." );
872- session .hash .reducetoSmallHash_v2 (100 );
873- System .gc ();
887+ // System.out.println("Reduction to small union DB...");
888+ // session.hash.reducetoSmallHash_v2(100);
889+ // System.gc();
874890 //calibration to small DB
875891 //NOTE: not done, we keep medium DB calibration as the basis.
876892 //now do placements on small DB
877- System .out .println ("Starting placement on small union DB..." );
878- placer =new Main_PLACEMENT_v07 (session ,dbInRAM );
879- for (int i = 0 ; i < queries .size (); i ++) {
880- File query = queries .get (i );
881- placer .doPlacements (query , dbsmallunion , workDir , callString , nsBound ,keepAtMost ,keepRatio );
882- }
893+ // System.out.println("Starting placement on small union DB...");
894+ // placer=new Main_PLACEMENT_v07(session,dbInRAM);
895+ // for (int i = 0; i < queries.size(); i++) {
896+ // File query = queries.get(i);
897+ // placer.doPlacements(query, dbsmallunion, workDir, callString, nsBound,keepAtMost,keepRatio);
898+ // }
883899 }
884900
885901 System .out .println ("DBINRAM OPERATIONS FINISHED." );
@@ -1101,30 +1117,30 @@ public static void DBGeneration( int analysisType,
11011117 session .hash .reducetoSmallHash_v2 (100 );
11021118 System .gc ();
11031119 //calibration
1104- float calibrationNormScoreSmallUnion =Float .NEGATIVE_INFINITY ;
1105- if (!noCalibration ) {
1106- if (writeTSVCalibrationLog ) {
1107- bwTSVCalibration =new BufferedWriter (new FileWriter (new File (logPath +"calibration_small.tsv" )),bufferSize );
1108- }
1109- System .out .println ("Score calibration on " +calibrationSampleSize +" random sequences (small union DB)..." );
1110- //do the placement and calculate score quantiles
1111- asp =new PlacementProcess (session ,Float .NEGATIVE_INFINITY , calibrationSampleSize );
1112- calibrationNormScoreSmallUnion = asp .processCalibration (rs ,calibrationSampleSize , null , SequenceKnife .SAMPLING_LINEAR , 0 ,q_quantile ,n_quantile );
1113- System .out .println ("Score bound: " +calibrationNormScoreSmallUnion );
1114- //closes the calibration log
1115- if (writeTSVCalibrationLog ){
1116- bwTSVCalibration .close ();
1117- }
1118- }
1120+ // float calibrationNormScoreSmallUnion=Float.NEGATIVE_INFINITY;
1121+ // if (!noCalibration) {
1122+ // if (writeTSVCalibrationLog) {
1123+ // bwTSVCalibration=new BufferedWriter(new FileWriter(new File(logPath+"calibration_small.tsv")),bufferSize);
1124+ // }
1125+ // System.out.println("Score calibration on "+calibrationSampleSize+" random sequences (small union DB)...");
1126+ // //do the placement and calculate score quantiles
1127+ // asp=new PlacementProcess(session,Float.NEGATIVE_INFINITY, calibrationSampleSize);
1128+ // calibrationNormScoreSmallUnion = asp.processCalibration(rs,calibrationSampleSize, null, SequenceKnife.SAMPLING_LINEAR, 0,q_quantile,n_quantile);
1129+ // System.out.println("Score bound: "+calibrationNormScoreSmallUnion);
1130+ // //closes the calibration log
1131+ // if (writeTSVCalibrationLog){
1132+ // bwTSVCalibration.close();
1133+ // }
1134+ // }
11191135 //associate medium calibration
1120- session .associateCalibrationScore (calibrationNormScoreSmallUnion );
1136+ // session.associateCalibrationScore(calibrationNormScoreSmallUnion);
11211137 //store in DB
1122- System .out .println ("Serialization of the database (small union)..." );
1123- session .storeHash (dbsmallunion );
1138+ // System.out.println("Serialization of the database (small union)...");
1139+ // session.storeHash(dbsmallunion);
11241140
11251141 //serialization finished, output some log infos
11261142 Infos .println ("DB UNION: " +Environement .getFileSize (dbunion )+" Mb saved" );
1127- Infos .println ("DB SMALL-UNION: " +Environement .getFileSize (dbsmallunion )+" Mb saved" );
1143+ // Infos.println("DB SMALL-UNION: "+Environement.getFileSize(dbsmallunion)+" Mb saved");
11281144 System .out .println ("\" Union\" database saved." );
11291145 }
11301146
0 commit comments