public static Element overlap_Genes( Document doc, String chr, int start, int end, IndividualStat is) { Element genes = doc.createElement(Consts.XML_TAG_GENES); doc.getElementsByTagName(Consts.DATA_ROOT).item(0).appendChild(genes); if (ChrMap.containsKey(chr)) { int[] range = binarySearchOverlap(ChrMap.get(chr), start, end); if (range != null) { float[] scores = null; if (is != null) scores = is.get_GeneScores(range[1], range[0]); for (int i = range[0]; i <= range[1]; i++) { Element gene = doc.createElement(Consts.XML_TAG_GENE); gene.setAttribute(Consts.XML_TAG_ID, Symbols[i]); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_FROM, Integer.toString(Starts[i] + 1)); XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_TO, Integer.toString(Ends[i])); if (is != null) XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_SCORE, Float.toString(Math.round(scores[i - range[0]] * 10) / 10)); genes.appendChild(gene); } } } return genes; }
public static Element ranking_Genes(Document doc, IndividualStat is, int number) { Element genes = doc.createElement(Consts.XML_TAG_GENES); doc.getElementsByTagName(Consts.DATA_ROOT).item(0).appendChild(genes); float[] scores = null; Integer[] index; if (number > Symbols.length) number = Symbols.length; if (is != null) { index = is.get_Order(); scores = is.get_GeneScores(Symbols.length - 1, 0); for (int i = Symbols.length - 1; i >= Symbols.length - number; i--) { Element gene = doc.createElement(Consts.XML_TAG_GENE); gene.setAttribute(Consts.XML_TAG_ID, Symbols[index[i]]); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_CHROMOSOME, ChrList[Chrs[index[i]]]); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_FROM, Integer.toString(Starts[index[i]] + 1)); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_TO, Integer.toString(Ends[index[i]])); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_SCORE, Float.toString(Math.round(scores[index[i]] * 10) / 10)); genes.appendChild(gene); } } return genes; }
public static Element find_Gene(Document doc, String prefix) { prefix = prefix.toUpperCase(); if (prefix.matches("C[XY0-9]+ORF")) { prefix = prefix.replaceFirst("ORF", "orf"); } else if (prefix.matches("C[XY0-9]+OR")) { prefix = prefix.replaceFirst("OR", "or"); } else if (prefix.matches("^C[XY0-9]+O")) { prefix = prefix.replaceFirst("O", "o"); } Element genes = doc.createElement(Consts.XML_TAG_GENES); doc.getElementsByTagName(Consts.DATA_ROOT).item(0).appendChild(genes); int match = binarySearchPrefix(prefix); if (match >= 0) { for (int i = match; i < match + 5; i++) { if (i >= Symbols_sorted.length || !Symbols_sorted[i].startsWith(prefix)) return genes; else { Element gene = doc.createElement(Consts.XML_TAG_GENE); gene.setAttribute(Consts.XML_TAG_ID, Symbols_sorted[i]); int index = SymbolMap.get(Symbols_sorted[i]); XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_CHROMOSOME, ChrList[Chrs[index]]); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_FROM, Integer.toString(Starts[index] + 1)); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_TO, Integer.toString(Ends[index])); genes.appendChild(gene); } } } return genes; }
public static Element gene_Info(Document doc, String symbol) { Element genes = doc.createElement(Consts.XML_TAG_GENES); doc.getElementsByTagName(Consts.DATA_ROOT).item(0).appendChild(genes); if (SymbolMap.containsKey(symbol)) { int index = SymbolMap.get(symbol); Element gene = doc.createElement(Consts.XML_TAG_GENE); gene.setAttribute(Consts.XML_TAG_ID, Symbols[index]); genes.appendChild(gene); XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_CHROMOSOME, ChrList[Chrs[index]]); XmlWriter.append_text_element( doc, gene, Consts.XML_TAG_FROM, Integer.toString(Starts[index] + 1)); XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_TO, Integer.toString(Ends[index])); if (!RefSeqs[index].equals("")) XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_REFSEQ, RefSeqs[index]); if (!UCSCs[index].equals("")) XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_UCSC, UCSCs[index]); if (!Ensembls[index].equals("")) XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_ENSEMBL, Ensembls[index]); if (!Entrezs[index].equals("")) XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_ENTREZ, Entrezs[index]); XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_HGNC, HGNCs[index]); XmlWriter.append_text_element(doc, gene, Consts.XML_TAG_NAME, Names[index]); } return genes; }