Ejemplo n.º 1
0
  public void run(String[] args) {

    DatabaseFactory factory = new DatabaseFactory();
    if (System.getProperty("user.dir").isEmpty()) {
      System.out.println("user.dir is incorrect");
    }
    if (System.getProperty("fizteh.db.dir").isEmpty()) {
      System.out.println("fizteh.db.dir is incorrect");
    }

    Path pathDirection =
        Paths.get(System.getProperty("user.dir")).resolve(System.getProperty("fizteh.db.dir"));

    String dir = pathDirection.toString();

    DatabaseProvider dProvider = factory.create(dir);

    if (args.length == 0) {

      interactiveMode(dProvider);
    } else {

      pocketMode(args, dProvider);
    }
  }
Ejemplo n.º 2
0
 /* takes the two experiment ids for which to retrieve data.
  */
 public PairedSQLData(int one, int two) throws SQLException {
   exptone = one;
   expttwo = two;
   try {
     corecxn = DatabaseFactory.getConnection("core");
   } catch (UnknownRoleException ex) {
     throw new DatabaseException("Couldn't connect with role core", ex);
   } catch (SQLException ex) {
     throw new DatabaseException("Couldn't connect to database for role core", ex);
   }
   try {
     chipcxn = DatabaseFactory.getConnection("chipchip");
     basicstmt =
         chipcxn.prepareStatement(
             "select a.channelone, a.channeltwo, a.ratio, b.channelone, b.channeltwo, b.ratio "
                 + " from data a, data b where a.probe = b.probe and a.experiment = ? and "
                 + " b.experiment = ?");
     samplestmt =
         chipcxn.prepareStatement(
             "select * from (select a.channelone, a.channeltwo, a.ratio, b.channelone, b.channeltwo, b.ratio, dbms_random.value as randval "
                 + " from data a, data b where a.probe = b.probe and a.experiment = ? and "
                 + " b.experiment = ? order by dbms_random.value) where randval < ?");
     limitstmt =
         chipcxn.prepareStatement(
             "select aone, atwo, arat, bone, btwo, brat from (select a.channelone aone, a.channeltwo atwo, a.ratio arat, b.channelone bone, b.channeltwo btwo, b.ratio brat "
                 + " from data a, data b where a.probe = b.probe and a.experiment = ? and "
                 + " b.experiment = ? order by dbms_random.value) where rownum < ?");
   } catch (UnknownRoleException ex) {
     throw new DatabaseException("Couldn't connect with role chipchip", ex);
   } catch (SQLException ex) {
     throw new DatabaseException("Couldn't connect to database for role chipchip", ex);
   }
 }
Ejemplo n.º 3
0
  public ExptLocatorTree(Genome g) {
    super();
    try {
      java.sql.Connection c = DatabaseFactory.getConnection(ExptLocator.dbRole);
      int species = g.getSpeciesDBID();
      int genome = g.getDBID();

      Statement s = c.createStatement();
      ResultSet rs = null;

      rs =
          s.executeQuery(
              "select e.name, e.version from experiment e, exptToGenome eg where e.active=1 and "
                  + "e.id=eg.experiment and eg.genome="
                  + genome);
      while (rs.next()) {
        String name = rs.getString(1);
        String version = rs.getString(2);
        ChipChipLocator loc = new ChipChipLocator(g, name, version);
        this.addElement(loc.getTreeAddr(), loc);
      }
      rs.close();

      rs =
          s.executeQuery(
              "select ra.name, ra.version from rosettaanalysis ra, rosettaToGenome rg where "
                  + "ra.id = rg.analysis and ra.active=1 and rg.genome="
                  + genome);
      while (rs.next()) {
        String name = rs.getString(1);
        String version = rs.getString(2);
        MSPLocator msp = new MSPLocator(g, name, version);
        this.addElement(msp.getTreeAddr(), msp);
      }
      rs.close();

      rs =
          s.executeQuery(
              "select ra.name, ra.version from bayesanalysis ra, bayesToGenome rg where "
                  + "ra.id = rg.analysis and ra.active=1 and rg.genome="
                  + genome);
      while (rs.next()) {
        String name2 = rs.getString(1);
        String version2 = rs.getString(2);
        ExptLocator loc2 = new BayesLocator(g, name2, version2);
        addElement(loc2.getTreeAddr(), loc2);
      }
      rs.close();
      s.close();

      DatabaseFactory.freeConnection(c);
    } catch (SQLException se) {
      se.printStackTrace(System.err);
      throw new RuntimeException(se);
    } catch (UnknownRoleException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 4
0
 public void close() {
   try {
     basicstmt.close();
     DatabaseFactory.freeConnection(corecxn);
     DatabaseFactory.freeConnection(chipcxn);
     corecxn = null;
     chipcxn = null;
     basicstmt = null;
   } catch (SQLException e) {
     throw new DatabaseException(e.toString(), e);
   }
 }