Пример #1
0
 void addGoTerms(OntGene gene, ArrayList<String> terms, OntDAG DAG) {
   int i = 0;
   OntTerm parent = null;
   for (i = 0; i < terms.size(); i++) {
     parent = DAG.getTerm(terms.get(i));
     if (parent != null) {
       parent.addOntTerm(gene);
     }
   }
 }
Пример #2
0
  public OntGeneAssociations readFile(OntDAG DAG, HashSet<String> useGenes) throws IOException {
    BufferedReader is = new BufferedReader(new FileReader(fName));
    String line = "";
    String s = "";
    line = is.readLine();
    int i = 0;

    String[] colNames = new String[15];
    String[] cols = null;
    String[] cols2 = null;

    while (!line.contentEquals("!platform_table_begin")) {
      line = is.readLine();
    }

    line = is.readLine();
    colNames = line.split("\t");

    line = is.readLine();
    OntGene gene = null;
    OntGeneAssociations assoc = new OntGeneAssociations();
    ArrayList<String> GoIDs = null;
    int numGenes = 0;
    boolean useGene = false;
    while (!line.contentEquals("!platform_table_end")) {
      cols = line.split("\t");
      cols2 = new String[15];
      for (i = 0; i < cols.length; i++) {
        cols2[i] = "";
      }
      for (i = 0; i < cols.length; i++) {
        cols2[i] = cols[i];
      }
      cols = cols2;

      gene = new OntGene();
      if (!useREFSEQ) {
        gene.ID = cols[0];
      } else {
        if (cols[3] != null) {
          gene.ID = cols[3];
        } else {
          gene.ID = cols[0];
        }
      }

      // see if the gene is in the filter list
      useGene = true;
      if (useGenes != null) {
        useGene = useGenes.contains(gene.ID);
      }

      if (!assoc.checkGene(gene) && useGene) {
        gene.Description = cols[7];
        gene.Name = cols[8];
        gene.REFSEQ = cols[3];

        GoIDs = parseGoLine(cols[12]);
        addGoTerms(gene, GoIDs, DAG);

        GoIDs = parseGoLine(cols[13]);
        addGoTerms(gene, GoIDs, DAG);

        GoIDs = parseGoLine(cols[14]);
        addGoTerms(gene, GoIDs, DAG);

        assoc.addGene(gene);
        numGenes++;
      }

      line = is.readLine();
    }

    is.close();

    DAG.propagateGeneCounts();
    return assoc;
  }