Пример #1
0
 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;
 }
Пример #2
0
 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;
 }