コード例 #1
0
  public BlastResult performTBlastn(File pssm, File db) {

    Runtime rt = Runtime.getRuntime();

    BlastResult result = null;

    try {

      String db_path = db.getAbsolutePath();

      //			db_path = db_path.substring(0, db_path.lastIndexOf('.')-1);

      String commandline =
          tblastn_exec_path
              + " -in_pssm "
              + pssm.getAbsolutePath()
              + " -db "
              + db_path
              + " -outfmt 6";

      Process pr = rt.exec(commandline);

      BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));

      String line = null;

      double minEvalue = 0.01;

      while ((line = in.readLine()) != null) {

        BlastResult r = new BlastResult();

        r.parse(line);

        if (r.getEvalue() < minEvalue) {

          result = r;

          minEvalue = r.getEvalue();
        }
      }

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return result;
  }
コード例 #2
0
  /**
   * @param args
   * @throws IOException
   */
  public static void main(String[] args) throws IOException {

    MassiveTblastnPicorna mbxp = new MassiveTblastnPicorna();

    List<String> subjectGI =
        mbxp.getSubjectGI(
            new File("/home/javier/Dropbox/Posdoc/PICORNAVIRIDAE/separateByProt/queriesGI"));

    Map<String, String> genomes =
        mbxp.loadGenomes(
            subjectGI, new File("/home/javier/Dropbox/Posdoc/PICORNAVIRIDAE/PICORNAVIRIDAE.fas"));

    File tmp_fasta = new File("/home/javier/Dropbox/Posdoc/PICORNAVIRIDAE/separateByProt/tmp.fas");

    File tmp_db = new File("/home/javier/Dropbox/Posdoc/PICORNAVIRIDAE/separateByProt/tmp");

    PrintStream out =
        new PrintStream(
            "/home/javier/Dropbox/Posdoc/PICORNAVIRIDAE/separateByProt/tblastn.results");

    List<File> pssms = new ArrayList<File>();

    for (int i = 1; i < 12; i++) {

      String number = String.format("%02d", i);

      pssms.add(
          new File(
              "/home/javier/Dropbox/Posdoc/PICORNAVIRIDAE/separateByProt/ORF" + number + ".pssm"));
    }

    for (String string : subjectGI) {
      // Iterate over each genome

      String genome_sequence = genomes.get(string);

      mbxp.exportTmpFasta(genome_sequence, string, tmp_fasta);

      mbxp.makeblastdb(tmp_fasta, tmp_db);

      for (int i = 0; i < 11; i++) {
        // Iterate over each protein
        File orf_pssm = pssms.get(i);

        BlastResult result = mbxp.performTBlastn(orf_pssm, tmp_db);

        if (result != null) {

          String out_seq;

          int beginIndex = Math.min(result.getSubjectStart(), result.getSubjectEnd());

          int endIndex = Math.max(result.getSubjectStart(), result.getSubjectEnd());

          out_seq = genome_sequence.substring(beginIndex - 1, endIndex);

          if (result.getSubjectStart() > result.getSubjectEnd()) {

            out_seq = Complementary.reverseComplementary(out_seq);
          }

          out.println(">" + string + "|ORF" + String.format("%02d", i + 1));

          out.println(out_seq);
        }
      }

      System.out.println("Genome " + string + " Done.");
    }

    out.close();
  }