Esempio n. 1
0
  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;
  }
Esempio n. 2
0
  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;
  }