Example #1
0
  /**
   * Parse a bufferedReader and process GFF3 record
   *
   * @param bReader the Reader
   * @throws java.io.IOException if an error occurs reading GFF
   * @throws ObjectStoreException if an error occurs storing items
   */
  public void parse(BufferedReader bReader) throws IOException, ObjectStoreException {
    GFF3Record record;
    long start, now, opCount;

    opCount = 0;
    start = System.currentTimeMillis();
    boolean duplicates = false;
    Set<String> processedIds = new HashSet<String>();
    Set<String> duplicatedIds = new HashSet<String>();
    for (Iterator<?> i = GFF3Parser.parse(bReader); i.hasNext(); ) {
      record = (GFF3Record) i.next();

      // we only care about dupes if we are NOT creating locations
      if (processedIds.contains(record.getId()) && dontCreateLocations) {
        duplicates = true;
        duplicatedIds.add(record.getId());
      } else {
        if (record.getId() != null) {
          processedIds.add(record.getId());
        }
      }
      if (!duplicates) {
        process(record);
      }
      opCount++;
      if (opCount % 1000 == 0) {
        now = System.currentTimeMillis();
        LOG.info("processed " + opCount + " lines --took " + (now - start) + " ms");
        start = System.currentTimeMillis();
      }
    }
    if (duplicates) {
      LOG.error("Duplicated IDs in GFF file: " + duplicatedIds);
      throw new IllegalArgumentException("Duplicated IDs in GFF file: " + duplicatedIds);
    }
  }