コード例 #1
0
ファイル: KEGGReactionService.java プロジェクト: pcm32/mdk
  public IdentifierReaction<KEGGCompoundIdentifier> getReaction(String accession)
      throws SQLException {

    statement.setString(1, accession);
    statement.execute();

    ResultSet rs = statement.getResultSet();

    IdentifierReaction<KEGGCompoundIdentifier> rxn = factory.newInstance(IdentifierReaction.class);

    while (rs.next()) {

      Double coefficient = rs.getDouble(1);
      String cpd = rs.getString(2);
      String ec = rs.getString(3);

      Participant<KEGGCompoundIdentifier, Double> base = factory.newInstance(Participant.class);

      Participant<KEGGCompoundIdentifier, Double> p =
          (Participant<KEGGCompoundIdentifier, Double>) base.newInstance();
      p.setMolecule(new KEGGCompoundIdentifier(cpd));

      if (coefficient > 0) {
        p.setCoefficient(coefficient);
        rxn.addProduct(p);
      } else if (coefficient < 0) {
        p.setCoefficient(Math.abs(coefficient));
        rxn.addReactant(p);
      }
    }

    return rxn;
  }
コード例 #2
0
ファイル: KEGGReactionService.java プロジェクト: pcm32/mdk
  public Collection<IdentifierReaction<KEGGCompoundIdentifier>> getReaction(ECNumber ec)
      throws SQLException {

    selectOnEC.setString(1, ec.toString());
    selectOnEC.execute();

    ResultSet rs = selectOnEC.getResultSet();

    Collection<IdentifierReaction<KEGGCompoundIdentifier>> reactions =
        new ArrayList<IdentifierReaction<KEGGCompoundIdentifier>>();

    String currentaccession = "";
    IdentifierReaction<KEGGCompoundIdentifier> rxn = null;

    while (rs.next()) {

      Double coefficient = rs.getDouble(1);
      String cpd = rs.getString(2);
      String accession = rs.getString(3);

      if (!accession.equals(currentaccession)) {

        if (rxn != null) reactions.add(rxn);

        currentaccession = accession;
        rxn = factory.newInstance(IdentifierReaction.class);

        rxn.setIdentifier(new KEGGReactionIdentifier(accession));
        rxn.setName(accession);
        rxn.setAbbreviation(accession);
      }

      Participant<KEGGCompoundIdentifier, Double> base = factory.newInstance(Participant.class);

      Participant<KEGGCompoundIdentifier, Double> p =
          (Participant<KEGGCompoundIdentifier, Double>) base.newInstance();
      p.setMolecule(new KEGGCompoundIdentifier(cpd));

      if (coefficient > 0) {
        p.setCoefficient(coefficient);
        rxn.addProduct(p);
      } else if (coefficient < 0) {
        p.setCoefficient(Math.abs(coefficient));
        rxn.addReactant(p);
      }
    }

    if (rxn != null) reactions.add(rxn);

    return reactions;
  }
コード例 #3
0
ファイル: ReactionParser.java プロジェクト: johnmay/metingear
  public MetabolicReaction getReaction(PreparsedReaction preparsed) {

    MetabolicReaction rxn =
        factory.ofClass(
            MetabolicReaction.class,
            BasicReactionIdentifier.nextIdentifier(),
            preparsed.hasValue(DESCRIPTION) ? preparsed.getValue(DESCRIPTION) : "",
            preparsed.hasValue(ABBREVIATION) ? preparsed.getValue(ABBREVIATION) : "");

    if (preparsed.hasValue(DIRECTION)) {
      rxn.setDirection(getReactionArrow(preparsed.getValue(DIRECTION)));
    } else {
      rxn.setDirection(getReactionArrow(preparsed.getEquation()));
    }

    // add subsytem annotation
    if (preparsed.hasValue(SUBSYSTEM)) {
      rxn.addAnnotation(new Subsystem(preparsed.getSubsystem()));
    }

    // add classification
    for (String classification : preparsed.getClassifications()) {
      // load EC code
      if (classification.matches("(?:\\d+\\.){3}\\d+") || classification.contains("EC")) {
        rxn.addAnnotation(new EnzymeClassification(new ECNumber(classification)));
      } else if (classification.contains("TC")) {
        rxn.addAnnotation(new Classification(new TransportClassificationNumber(classification)));
      }
    }

    // add loci
    for (String locus : preparsed.getLoci()) {
      rxn.addAnnotation(new Locus(locus));
    }

    // add delta g and delta g error
    if (preparsed.hasValue(FREE_ENERGY)) {
      try {
        if (preparsed.hasValue(FREE_ENERGY_ERROR)) {
          rxn.addAnnotation(
              new GibbsEnergy(
                  Double.parseDouble(preparsed.getValue(FREE_ENERGY)),
                  Double.parseDouble(preparsed.getValue(FREE_ENERGY_ERROR))));
        } else {
          rxn.addAnnotation(
              new GibbsEnergy(Double.parseDouble(preparsed.getValue(FREE_ENERGY)), 0d));
        }
      } catch (NumberFormatException ex) {
        LOGGER.error("Gibbs energy column(s) contained invalid value (not a double)");
      }
    }

    if (preparsed.hasValue(MIN_FLUX)) {
      try {
        rxn.addAnnotation(new FluxLowerBound(Double.parseDouble(preparsed.getValue(MIN_FLUX))));
      } catch (NumberFormatException ex) {
        LOGGER.error(
            "Min flux column contained invalid value (not a double): "
                + preparsed.getValue(MIN_FLUX));
      }
    }

    if (preparsed.hasValue(MAX_FLUX)) {
      try {
        rxn.addAnnotation(new FluxLowerBound(Double.parseDouble(preparsed.getValue(MAX_FLUX))));
      } catch (NumberFormatException ex) {
        LOGGER.error(
            "Max flux column contained invalid value (not a double): "
                + preparsed.getValue(MAX_FLUX));
      }
    }

    return rxn;
  }