@@ -42,27 +42,27 @@ public static boolean parseStringforInvalideNuc(String seq) {
4242 * chr2 813184 234067 60 61
4343 */
4444 public static boolean buildFASTAIndex (File fasta ) throws IOException {
45- boolean properFASTA = true ;
46- ArrayList <String > IMPROPER_FASTA = new ArrayList <String >();
47- int counter = 0 ;
48-
49- String contig = "" ;
50- int binaryOffset = 0 ;
51- int currentOffset = 0 ;
52- int contigLength = 0 ;
53- int column_Length = 0 ;
54- int untrimmed_Column_Length = 0 ;
55-
56- BufferedReader b_read = new BufferedReader (new FileReader (fasta ));
57- LineReader reader = new LineReader (b_read );
58- PrintStream FAI = new PrintStream (fasta .getCanonicalPath () + ".fai" );
59-
60- String strLine = "" ;
61- while (!(strLine = reader .readLine ()).equals ("" )) {
62- //Pull parameters line
63- int current_untrimmed_Column_Length = strLine .length ();
64- int current_column_Length = strLine .trim ().length ();
65-
45+ boolean properFASTA = true ;
46+ ArrayList <String > IMPROPER_FASTA = new ArrayList <String >();
47+ long counter = 0 ;
48+
49+ String contig = "" ;
50+ long binaryOffset = 0 ;
51+ long currentOffset = 0 ;
52+ long contigLength = 0 ;
53+ long column_Length = 0 ;
54+ long untrimmed_Column_Length = 0 ;
55+
56+ BufferedReader b_read = new BufferedReader (new FileReader (fasta ));
57+ LineReader reader = new LineReader (b_read );
58+ PrintStream FAI = new PrintStream (fasta .getCanonicalPath () + ".fai" );
59+
60+ String strLine = "" ;
61+ while (!(strLine = reader .readLine ()).equals ("" )) {
62+ //Pull parameters line
63+ long current_untrimmed_Column_Length = strLine .length ();
64+ long current_column_Length = strLine .trim ().length ();
65+
6666 if (strLine .contains (">" )) {
6767 if (IMPROPER_FASTA .size () > 1 ) {
6868 System .out .println ("Unequal column size FASTA Line at:" );
@@ -84,19 +84,19 @@ public static boolean buildFASTAIndex(File fasta) throws IOException {
8484 if (column_Length == 0 ) { column_Length = current_column_Length ; }
8585 binaryOffset += current_untrimmed_Column_Length ;
8686 contigLength += current_column_Length ;
87-
87+
8888 //Check to make sure all the columns are equal. Index is invalid otherwise
8989 if (current_untrimmed_Column_Length != untrimmed_Column_Length || current_untrimmed_Column_Length == 0 ) { IMPROPER_FASTA .add (strLine .trim ()); }
9090 }
9191 counter ++;
92- }
92+ }
9393 FAI .println (contig + "\t " + contigLength + "\t " + currentOffset + "\t " + column_Length + "\t " + untrimmed_Column_Length );
9494 b_read .close ();
95- FAI .close ();
96-
95+ FAI .close ();
96+
9797 if (properFASTA ) System .out .println ("Genome Index Built" );
9898 else { new File (fasta .getName () + ".fai" ).delete (); }
99-
99+
100100 return properFASTA ;
101101 }
102102}
0 commit comments