public void setUp() throws Exception {
    tgtModel = Model.getInstanceByName("genomic");

    handler = new FlyRegGFF3RecordHandler(tgtModel);

    handler.rslv = IdResolverService.getMockIdResolver("Gene");
    handler.rslv.addResolverEntry("7227", "FBgn001", Collections.singleton("dpp"));
    handler.rslv.addResolverEntry("7227", "FBgn002", Collections.singleton("dl"));

    converter =
        new GFF3Converter(
            writer, seqClsName, taxonId, dataSourceName, dataSetTitle, tgtModel, handler, null);
  }
Exemplo n.º 2
0
  /**
   * Process the csv file
   *
   * @param reader the Reader
   * @see DataConverter#process
   * @throws Exception if something goes wrong
   */
  @Override
  public void process(Reader reader) throws Exception {
    if (rslv == null) {
      rslv = IdResolverService.getFlyIdResolver();
    }

    Iterator<String[]> it = FormattedTextParser.parseTabDelimitedReader(reader);

    while (it.hasNext()) {

      String[] lineBits = it.next();
      String geneCG = lineBits[0];

      if (!geneCG.startsWith("CG")) {
        // ignore clones for now
        continue;
      }

      // Try to create/fetch gene, if null the IdResolver failed so do nothing for this row
      Item gene = getGene(geneCG);
      if (gene == null) {
        continue;
      }

      String stage = lineBits[1];

      String resultKey = geneCG + stage;
      Item result = getResult(resultKey, gene.getIdentifier(), pub.getIdentifier(), stage);

      Integer stageNumber = null;
      try {
        stageNumber = new Integer(stage);
      } catch (NumberFormatException e) {
        // bad line in file, just keep going
        continue;
      }
      result.setAttribute("stageRange", STAGE_LABELS[stageNumber.intValue()] + " (BDGP in situ)");

      if (lineBits.length > 2) {
        String image = lineBits[2];
        if (StringUtils.isNotEmpty(image)) {
          setImage(result, URL + image);
        }
      }
      if (lineBits.length > 3) {
        String term = lineBits[3];
        Item termItem = getTerm(term);
        if (termItem != null) {
          result.addToCollection("mRNAExpressionTerms", termItem);
        }
        if ("no staining".equals(term)) {
          result.setAttribute("expressed", "false");
        }
      }
    }

    for (Item result : results.values()) {
      if (!result.hasCollection("mRNAExpressionTerms")
          || result.getCollection("mRNAExpressionTerms").getRefIds().isEmpty()) {
        result.setAttribute("expressed", "false");
      }
    }

    storeAll(imgs);
    storeAll(results);
  }