private void parseGenePositionText() { String genomeID = hic.getDataset().getGenomeId(); // Currently only human and mouse, not worrying about small differences in location between // genomes if (genomeID.equals("b37")) genomeID = "hg19"; if (geneLocationHashMap == null || !genomeID.equals(this.genomeID)) { initializeGeneHashMap(genomeID); } else { extractGeneLocation(); } }
private void unsafeInitializeGeneHashMap(String genomeID) { // Custom format parsed from ref Gene file. // Name1 Name2 chromosome position (where position is midpoint of transcription start and end) String path = "http://hicfiles.s3.amazonaws.com/internal/" + genomeID + "_refGene.txt"; BufferedReader reader; try { SeekableHTTPStream stream = new SeekableHTTPStream(new URL(path)); reader = new BufferedReader(new InputStreamReader(stream), HiCGlobals.bufferSize); MessageUtils.showMessage( "Loading gene database for " + genomeID + ".\nIt might take a minute or so. "); } catch (Exception error) { MessageUtils.showErrorMessage("Failed to read gene database", error); positionChrTop.setBackground(Color.yellow); geneLocationHashMap = null; return; } geneLocationHashMap = new HashMap<String, GeneLocation>(); String nextLine; try { while ((nextLine = reader.readLine()) != null) { String[] values = nextLine.split(" "); GeneLocation location = new GeneLocation(values[2].trim(), Integer.valueOf(values[3].trim())); geneLocationHashMap.put(values[0].trim().toLowerCase(), location); geneLocationHashMap.put(values[1].trim().toLowerCase(), location); } } catch (Exception error) { MessageUtils.showErrorMessage("Failed to parse gene database", error); positionChrTop.setBackground(Color.yellow); geneLocationHashMap = null; } if (geneLocationHashMap != null) this.genomeID = genomeID; extractGeneLocation(); }