Exemplo n.º 1
0
 @Transactional
 private void loadFile(String filename)
     throws IOException, ParsingException, FileNotFoundException, DataError {
   File file = new File(filename);
   EmblFile emblFile = new EmblFile(file, new FileReader(file));
   loader.load(emblFile);
   logger.debug("Finished loading");
 }
Exemplo n.º 2
0
 /**
  * Reload the same file as before, with the <tt>overwriteExisting</tt> flag set.
  *
  * @throws ParsingException
  * @throws IOException
  */
 public void reload() throws IOException, ParsingException {
   if (this.filename == null) {
     throw new IllegalStateException("Filename not set");
   }
   logger.info("Reloading file: " + filename);
   loader.setOverwriteExisting(OverwriteExisting.YES);
   loadFile(filename);
 }
Exemplo n.º 3
0
  private void doLoad(
      String organismCommonName,
      String organismGenus,
      String organismSpecies,
      String organismStrain,
      String filename)
      throws IOException, ParsingException {

    if (organismGenus != null) {
      createOrganismIfNecessary(organismCommonName, organismGenus, organismSpecies, organismStrain);
    }

    loader.setReportUnusedQualifiers(true);
    loader.setOrganismCommonName(organismCommonName);
    loadFile(filename);
    this.filename = filename;
  }
Exemplo n.º 4
0
 private void quickAndDirty() {
   alwaysSkip();
   loader.setContinueOnError(true);
   continueOnError = true;
 }
Exemplo n.º 5
0
 @Override
 protected void processFile(File inputFile, Reader reader) throws IOException, ParsingException {
   EmblFile emblFile =
       new EmblFile(inputFile, reader, continueOnError, loader.getOverwriteExisting());
   loader.load(emblFile);
 }
Exemplo n.º 6
0
  private LoadEmbl(
      String organismCommonName,
      String overwriteExistingString,
      String topLevelFeatureType,
      boolean sloppyControlledCuration,
      boolean goTermErrorsAreNotFatal,
      String ignoreQualifiers,
      String ignoreFeatures) {
    EmblLoader.OverwriteExisting overwriteExisting;
    if (overwriteExistingString.equals("yes")) {
      overwriteExisting = EmblLoader.OverwriteExisting.YES;
    } else if (overwriteExistingString.equals("no")) {
      overwriteExisting = EmblLoader.OverwriteExisting.NO;
    } else if (overwriteExistingString.equals("merge")) {
      overwriteExisting = EmblLoader.OverwriteExisting.MERGE;
    } else {
      throw new RuntimeException(
          "Unrecognised value for load.overwriteExisting: " + overwriteExistingString);
    }

    ApplicationContext applicationContext =
        new ClassPathXmlApplicationContext(new String[] {"Load.xml"});

    // set this to true if you want to find out what the actual database connection is.
    boolean debug = false;
    if (debug == true) {
      org.apache.commons.dbcp.BasicDataSource ds =
          applicationContext.getBean("dataSource", org.apache.commons.dbcp.BasicDataSource.class);
      logger.info("Connecting to " + ds.getUrl() + " with username " + ds.getUsername());
    }

    this.loader = applicationContext.getBean("emblLoader", EmblLoader.class);
    loader.setOrganismCommonName(organismCommonName);
    loader.setOverwriteExisting(overwriteExisting);
    loader.setSloppyControlledCuration(sloppyControlledCuration);
    loader.setGoTermErrorsAreNotFatal(goTermErrorsAreNotFatal);

    if (topLevelFeatureType.equals("chromosome")) {
      loader.setTopLevelFeatureClass(Chromosome.class);
    } else if (topLevelFeatureType.equals("supercontig")) {
      loader.setTopLevelFeatureClass(Supercontig.class);
    } else if (topLevelFeatureType.equals("contig")) {
      loader.setTopLevelFeatureClass(Contig.class);
    } else if (topLevelFeatureType.equals("plasmid")) {
      loader.setTopLevelFeatureClass(Plasmid.class);
    } else if (topLevelFeatureType.equals("EST")) {
      loader.setTopLevelFeatureClass(EST.class);
    } else if (topLevelFeatureType.equals("BAC_end")) {
      loader.setTopLevelFeatureClass(BACEnd.class);
    } else if (topLevelFeatureType.equals("gene")) {
      loader.setTopLevelFeatureClass(Gene.class);
    } else {
      throw new RuntimeException(
          String.format("Unrecognised value for load.topLevel: '%s'", topLevelFeatureType));
    }

    if (ignoreQualifiers != null) {
      Matcher ignoreQualifiersMatcher = ignoreQualifiersPattern.matcher(ignoreQualifiers);
      int end = 0;
      while (ignoreQualifiersMatcher.find()) {
        end = ignoreQualifiersMatcher.end();

        String feature = ignoreQualifiersMatcher.group(1);
        String qualifier = ignoreQualifiersMatcher.group(2);
        if (feature == null) {
          loader.ignoreQualifier(qualifier);
        } else {
          loader.ignoreQualifier(qualifier, feature);
        }
      }
      if (end < ignoreQualifiersMatcher.regionEnd()) {
        throw new RuntimeException("Failed to parse load.ignoreQualifiers: " + ignoreQualifiers);
      }
    }

    if (ignoreFeatures != null) {
      Matcher ignoreFeaturesMatcher = ignoreFeaturesPattern.matcher(ignoreFeatures);
      while (ignoreFeaturesMatcher.find()) {
        loader.ignoreFeature(ignoreFeaturesMatcher.group(1));
      }
    }
  }