public Translation(Gene gene, Substance aa) { if (gene != null) { setGene(gene); setName("Translation_" + gene.getName()); setSystem(gene.getGeneticSystem()); } if (aa != null) { setAminoAcid(aa); } setToPrint(false); }
// print formatted info in no particular order public String getInfoString() { String s = "<HTML>"; // gene info if (geneInfoSet) { s += "<B>"; if (gene.getGeneType().equals(Gene.geneType.ENTREZ)) { s += "Entrez Gene"; } else if (gene.getGeneType().equals(Gene.geneType.ENSEMBL)) { s += "Ensembl Gene"; } s += "</B><BR>"; String name = gene.getName(); if (name != null) s += "Name: " + name + "<BR>"; String description = gene.getDescription(); if (description != null) s += "Description: " + description + "<BR>"; String chromosome = gene.getChromosome(); if (chromosome != null) s += "Chromosome: " + chromosome + "<BR>"; s += "Start: " + gene.getStart() + "<BR>"; s += "End: " + gene.getEnd() + "<BR>"; s += "<BR>"; } Iterator it = attributes.keySet().iterator(); while (it.hasNext()) { String node = (String) it.next(); if (node.equals("Graphics")) continue; s += "<B>" + node + "</B><BR>"; Iterator currentIt = attributes.get(node).keySet().iterator(); while (currentIt.hasNext()) { String key = (String) currentIt.next(); s += key + ": " + attributes.get(node).get(key) + "<BR>"; } s += "<BR>"; } s += "</HTML>"; return s; }
public boolean equals(Object o) { if (!(o instanceof Gene)) return false; Gene gene = (Gene) o; return gene.getName().compareTo(name) == 0; }
@Override public int compareTo(Gene gene) { return gene.getName().compareTo(name); }
@Override protected Void doInBackground() throws Exception { int count = 0; String sep = "\t"; try { PrintWriter writer = new PrintWriter(file); writer.write("Feature_Number" + sep); writer.write("Location" + sep); writer.write("Gene_name" + sep); writer.write("Gene_accession" + sep); writer.write("Gene_Location" + sep); writer.write("distance_to_tss" + "\n"); for (Region r : feature.getRegions()) { Peak peak = (Peak) r; String chrom = peak.chrom; if (geneData.hasKey(chrom)) { int index = geneData.getNCList(chrom).getOverlapIndex(peak); Vector<Region> preGenes = new Vector<Region>(); Vector<Region> nearGenes; Vector<Region> postGenes = new Vector<Region>(); if (index > 0) { preGenes = geneData.getNCList(chrom).getRegionsAt(index - 1); } nearGenes = geneData.getNCList(chrom).getRegionsAt(index); if (index + 1 < geneData.getNCList(chrom).size()) { postGenes = geneData.getNCList(chrom).getRegionsAt(index + 1); } nearGenes.addAll(preGenes); nearGenes.addAll(postGenes); Gene nearestGene = null; long min_dist = Long.MAX_VALUE; for (Region testPeak : nearGenes) { // print(testPeak.getClass().toString()); Gene g = (Gene) testPeak; long dist = getDistToTss(peak, g); if (dist < min_dist) { min_dist = dist; nearestGene = (Gene) testPeak; } } // end for, each close gene. writer.write(count + sep); writer.write(peak.getLocationString() + sep); writer.write(nearestGene.getName() + sep); writer.write(nearestGene.getAccession() + sep); writer.write(nearestGene.getLocationString() + sep); writer.write(min_dist + "\n"); } // end if, has same chromosome key ++count; } // end for, each peak region writer.close(); } catch (Exception ex) { ex.printStackTrace(); } return null; }