void createHelperMaps() {
intronIntervalTreeMap = new IntervalTreeMap<Integer>();
int numIntrons = 0;
for (Map.Entry<String,Gene> entry : geneMap.entrySet()) {
Gene gene = entry.getValue();
for (final Gene.Transcript tx : gene) {
int numExons = tx.exons.length;
if (numExons < 2) {
continue;
}
int[] breakCoords = new int[(numExons - 1)*2];
int k = 0;
if ( gene.isPositiveStrand() ) {
for (int i = 0; i < numExons; ++ i) {
Gene.Transcript.Exon e = tx.exons[i];
if (i == 0) {
breakCoords[k++] = e.end;
} else if ( i == numExons - 1) {
breakCoords[k++] = e.start;
} else {
breakCoords[k++] = e.start;
breakCoords[k++] = e.end;
}
}
} else {
// make sure there is no problem with sorting
Arrays.sort(tx.exons, new Comparator<Gene.Transcript.Exon>() {
@Override
public int compare(Gene.Transcript.Exon e1, Gene.Transcript.Exon e2) {
return e1.start > e2.start ? -1 : 1;
}
});
for (int i = numExons - 1; i >= 0; -- i) {
Gene.Transcript.Exon e = tx.exons[i];
if (i == 0) {
breakCoords[k++] = e.start;
} else if ( i == numExons - 1) {
breakCoords[k++] = e.end;
} else {
breakCoords[k++] = e.start;
breakCoords[k++] = e.end;
}
}
}
for (int i = 0; i < breakCoords.length; i+=2) {
String chrName = gene.getSequence();
Interval intronInterval = new Interval(chrName, breakCoords[i], breakCoords[i+1]);
numIntrons++;
intronIntervalTreeMap.put(intronInterval, numIntrons);
junctionLocationMap.put(chrName, breakCoords[i],breakCoords[i+1]);
}