Beispiel #1
0
  /** @param args */
  public static void main(String[] args) {
    initOptions();
    try {
      parse(args, false);

      String comm = args[1];

      String buildOption = null;

      // no needed to check as 'build' arg is required in Options
      if (!commandLine.hasOption("build") || commandLine.getOptionValue("build").equals("")) {}

      buildOption = commandLine.getOptionValue("build");

      if (buildOption.equals("genome-sequence")) {
        System.out.println("In genome-sequence");
        String indir = commandLine.getOptionValue("indir");
        String outfile = commandLine.getOptionValue("outfile", "/tmp/genome_sequence.json");
        if (indir != null) {
          GenomeSequenceFastaParser genomeSequenceFastaParser = new GenomeSequenceFastaParser();
          genomeSequenceFastaParser.parseFastaGzipFilesToJson(new File(indir), new File(outfile));
        }
      }

      if (buildOption.equals("core")) {
        System.out.println("In core");
        String gtfFile = commandLine.getOptionValue("gtf-file");
        String geneDescriptionFile = commandLine.getOptionValue("gene-description", "");
        String xrefFile = commandLine.getOptionValue("xref-file", "");
        String tfbsFile = commandLine.getOptionValue("tfbs-file", "");
        String mirnaFile = commandLine.getOptionValue("mirna-file", "");
        String genomeSequenceDir = commandLine.getOptionValue("genome-sequence-dir", "");
        String outfile = commandLine.getOptionValue("outfile", "/tmp/gene.json");
        if (gtfFile != null) {
          try {
            GeneParser geneParser = new GeneParser();
            geneParser.parse(
                new File(gtfFile),
                new File(geneDescriptionFile),
                new File(xrefFile),
                new File(tfbsFile),
                new File(mirnaFile),
                new File(genomeSequenceDir),
                new File(outfile));
          } catch (SecurityException | NoSuchMethodException | FileFormatException e) {
            e.printStackTrace();
          }
        }
      }

      if (buildOption.equals("variation")) {
        System.out.println("In variation");
        String indir = commandLine.getOptionValue("indir");
        int chunksize = Integer.parseInt(commandLine.getOptionValue("chunksize", "0"));
        System.out.println("chunksize: " + chunksize);
        String outfile = commandLine.getOptionValue("outfile", "/tmp/variation.json");
        if (indir != null) {
          VariationParser vp = new VariationParser();
          vp.createVariationDatabase(Paths.get(indir));

          vp.connect(Paths.get(indir));
          //					List<String> res = vp.queryByVariationId(13, "variation_synonym",
          // Paths.get(indir));
          //					System.out.println("a");
          //					 res = vp.queryByVariationId(4, "variation_synonym", Paths.get(indir));
          //					System.out.println("b");
          //					res = vp.queryByVariationId(8, "variation_synonym", Paths.get(indir));
          //					System.out.println("c");
          vp.parseVariationToJson("", "", "", "", Paths.get(indir), Paths.get(outfile));
          vp.disconnect();
        }
      }

      if (buildOption.equals("regulation")) {
        System.out.println("In regulation");
        String indir = commandLine.getOptionValue("indir");
        int chunksize = Integer.parseInt(commandLine.getOptionValue("chunksize", "0"));
        System.out.println("chunksize: " + chunksize);
        String outfile = commandLine.getOptionValue("outfile", "/tmp/regulations.json");
        if (indir != null) {
          try {
            RegulatoryParser.parseRegulatoryGzipFilesToJson(
                Paths.get(indir), chunksize, Paths.get(outfile));
          } catch (ClassNotFoundException | NoSuchMethodException | SQLException e) {
            e.printStackTrace();
          }
        }
      }

      if (buildOption.equals("conservation")) {
        System.out.println("In conservation");
        String indir = commandLine.getOptionValue("indir");
        int chunksize = Integer.parseInt(commandLine.getOptionValue("chunksize", "0"));
        String outfile = commandLine.getOptionValue("outfile", "/tmp/conservation.json");
        if (indir != null) {
          ConservedRegionParser.parseConservedRegionFilesToJson(
              Paths.get(indir), chunksize, Paths.get(outfile));
        }
      }

    } catch (ParseException | IOException | SQLException | ClassNotFoundException e) {
      e.printStackTrace();
    }
  }