public static void main(String[] argv) throws Exception {
    DriverManager.load(
        "org/ensembl/conf/current_driver.conf:org/ensembl/conf/kaka_mysql_server.conf");
    Controller c = new Controller();
    EnsJSequence seq =
        new EnsJSequence("Dummy", c, new AssemblyLocation("22", 20000000, 20100000, 0), "current");

    SequenceAdaptor sa = (SequenceAdaptor) DriverManager.get("current").getAdaptor("sequence");

    seq.getCacher().setMinChunkSize(100);
    System.out.println("Have sequence. Dumping regions");

    String processedSeq = seq.getResidues(1, 10);
    String rawSeq = sa.fetch(new AssemblyLocation("22", 20000000, 20000009, 0)).getString();
    String diff =
        (rawSeq.equals(processedSeq))
            ? "SAME"
            : "protected = " + processedSeq + "\nraw = " + rawSeq;
    System.out.println("Sequence first 10 = " + diff);

    processedSeq = seq.getResidues(100, 110);
    rawSeq = sa.fetch(new AssemblyLocation("22", 20000099, 20000109, 0)).getString();
    diff =
        (rawSeq.equals(processedSeq))
            ? "SAME"
            : "protected = " + processedSeq + "\nraw = " + rawSeq;
    System.out.println("Sequence 100-110 = " + diff);

    processedSeq = seq.getResidues(10000, 11010);
    rawSeq = sa.fetch(new AssemblyLocation("22", 20009999, 20011009, 0)).getString();
    diff =
        (rawSeq.equals(processedSeq))
            ? "SAME"
            : "protected = " + processedSeq + "\nraw = " + rawSeq;
    System.out.println("Sequence 10000-11010 = " + diff);

    processedSeq = seq.getResidues(1, 12010);
    rawSeq = sa.fetch(new AssemblyLocation("22", 20000000, 20012009, 0)).getString();
    diff =
        (rawSeq.equals(processedSeq))
            ? "SAME"
            : "protected = " + processedSeq + "\nraw = " + rawSeq;
    System.out.println("Sequence 1-12010 = " + diff);

    processedSeq = seq.getResidues(12010, 1);
    rawSeq = sa.fetch(new AssemblyLocation("22", 20000000, 20012009, -1)).getString();
    diff =
        (rawSeq.equals(processedSeq))
            ? "SAME"
            : "protected = " + processedSeq + "\nraw = " + rawSeq;
    System.out.println("Sequence 12010-1 = " + diff);
  }
  /* Note: low and high are relative coordinates */
  protected String getResiduesFromSourceImpl(int start, int end) {

    try {

      logger.debug(
          "getting sequence "
              + start
              + " to "
              + end
              + " from "
              + driverPath
              + " for seq obj "
              + this);
      SequenceAdaptor sa = (SequenceAdaptor) DriverManager.get(driverPath).getAdaptor("sequence");
      LinearLocation loc = derivedLocation(start, end);
      org.ensembl19.datamodel.Sequence seq = sa.fetch(loc);
      String s = seq.getString();
      logger.debug("s=" + start + "\te=" + end);
      logger.debug("EnsJSequence retrieved: " + s.length() + "\t" + s + "\t" + loc);

      return s;

    } catch (Exception e) {
      logger.error("Failed getting sequence residues", e);
      return null;
    }
  }
Beispiel #3
0
 protected boolean insertComment() throws SQLException {
   try {
     String dburl = getServletContext().getInitParameter("DBUrl");
     String dbuser = getServletContext().getInitParameter("DBUser");
     String dbpasswd = getServletContext().getInitParameter("DBPasswd");
     Class.forName("com.mysql.jdbc.Driver");
     conn = DriverManager.getConnection(dburl, dbuser, dbpasswd);
     String sqlqry = "INSERT INTO feedback (name, email, feedback) VALUES (?,?,?)";
     pstmt = conn.prepareStatement(sqlqry);
     pstmt.setString(1, name);
     pstmt.setString(2, email);
     pstmt.setString(3, comment);
     if (pstmt.executeUpdate() > 0) return true;
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     logger.error(e);
     e.printStackTrace();
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     logger.error(e);
     e.printStackTrace();
   } finally {
     conn.close();
     pstmt.close();
   }
   return false;
 }
  public static void main(String[] args) {
    // Ensure to have all necessary drivers installed !
    try {
      Driver d = (Driver) (Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
      DriverManager.registerDriver(d);
    } catch (Exception e) {
    }

    // Set the priority which messages have to be logged
    cat.setPriority(Priority.INFO);

    // Configuration with configuration-file
    PropertyConfigurator.configure("log4jtestprops.txt");

    // These messages with Priority >= setted priority will be logged to the database.
    cat.debug("debug"); // this not, because Priority DEBUG is less than INFO
    cat.info("info");
    cat.error("error");
    cat.fatal("fatal");
  }