Skip to content

Commit df730be

Browse files
author
William Lai
committed
INT overflow issue for mammalian genomes
Changed int to long to prevent overflow issues when indexing genomes greater than 2 gigabytes
1 parent de4cf42 commit df730be

2 files changed

Lines changed: 26 additions & 27 deletions

File tree

src/util/FASTAUtilities.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/window_interface/Sequence_Analysis/FASTAExtractWindow.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public Void doInBackground() throws IOException {
6969
JOptionPane.showMessageDialog(null, "No BAM Files Loaded!!!");
7070
} else {
7171
setProgress(0);
72-
System.out.println(rdbtnBedName.isSelected());
7372
FASTAExtract signal = new FASTAExtract(INPUT, BEDFiles, OUTPUT_PATH, chckbxStrand.isSelected(), rdbtnBedName.isSelected());
7473

7574
signal.addPropertyChangeListener("fa", new PropertyChangeListener() {

0 commit comments

Comments
 (0)