Exemplo n.º 1
0
  //    public PeptideCollection getCutoffCollection(double omssa, double mascot, double xtandem) {
  //        return getCutoffCollection(omssa, mascot, xtandem, false);
  //    }
  public PeptideCollection getCutoffCollection(FilterSettings fs) {
    PeptideCollection pc = new PeptideCollection();

    for (PeptideHit p : peptideHits) {
      if (fs.getUsePepProphet() && p.isPepXML()) {
        if (p.getPepProphet() >= fs.getPeptideProphetCutoff()) {
          pc.addPeptideHit(p);
        }
      } else {
        switch (p.getSourceType()) {
          case MASCOT:
            if (fs.getUseIonIdent()) {
              if (p.getIonScore() >= p.getIdent()) {
                pc.addPeptideHit(p);
              }
            } else if (p.getExpect() <= fs.getMascotCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case OMSSA:
            if (p.getExpect() <= fs.getOmssaCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case XTANDEM:
            if (p.getExpect() <= fs.getXtandemCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case SEQUEST:
            if (p.getExpect() <= fs.getSequestCutoff()) {
              pc.addPeptideHit(p);
            }
            break;
          case PEPXML:
            if (!p.CanGetPepProphet() || (p.getPepProphet() >= fs.getPeptideProphetCutoff())) {
              pc.addPeptideHit(p);
            }
            break;
        }
      }
    }

    return pc;
  }
Exemplo n.º 2
0
  @Deprecated
  // since its questionable whether this
  // is important enough to live in WordprocessingMLPackage,
  // and in any case probably should be replaced with a TraversalUtil
  // approach (which wouldn't involve marshal/unmarshall, and
  // so should be more efficient).
  public void filter(FilterSettings filterSettings) throws Exception {

    if (filterTemplate == null) { // first use
      Source xsltSource =
          new StreamSource(
              org.docx4j.utils.ResourceUtils.getResource(
                  "org/docx4j/openpackaging/packages/filter.xslt"));
      filterTemplate = XmlUtils.getTransformerTemplate(xsltSource);
    }
    transform(filterTemplate, filterSettings.getSettings());
  }
Exemplo n.º 3
0
  @Override
  public void accept(AisPacket packet) {
    if (out == null) {
      // Open new output stream
      out = getNextOutputStram();
    }

    end = System.currentTimeMillis();
    if (start == 0) {
      start = end;
    }

    for (IPacketFilter filter : filters) {
      if (filter.rejectedByFilter(packet)) {
        return;
      }
    }

    Integer baseMMSI = -1;
    String country = "";
    String region = "";

    Vdm vdm = packet.getVdm();
    if (vdm == null) {
      return;
    }

    // Get source tag properties
    IProprietarySourceTag sourceTag = vdm.getSourceTag();
    if (sourceTag != null) {
      baseMMSI = sourceTag.getBaseMmsi();
      if (sourceTag.getCountry() != null) {
        country = sourceTag.getCountry().getTwoLetter();
      }
      if (sourceTag.getRegion() != null) {
        region = sourceTag.getRegion();
      }
    }
    if (region.equals("")) {
      region = "0";
    }

    // Maybe check for start date
    Date timestamp = vdm.getTimestamp();
    if (filter.getStartDate() != null && timestamp != null) {
      if (timestamp.before(filter.getStartDate())) {
        return;
      }
    }

    // Maybe check for end date
    if (filter.getEndDate() != null && timestamp != null) {
      if (timestamp.after(filter.getEndDate())) {
        System.exit(0);
      }
    }

    // Maybe check for base station MMSI
    if (filter.getBaseStations().size() > 0) {
      if (!filter.getBaseStations().contains(baseMMSI)) {
        return;
      }
    }

    // Maybe check for country
    if (filter.getCountries().size() > 0) {
      if (!filter.getCountries().contains(country)) {
        return;
      }
    }

    // Maybe check for region
    if (filter.getRegions().size() > 0) {
      if (!filter.getRegions().contains(region)) {
        return;
      }
    }

    if (stop) {
      return;
    }

    // Count message
    msgCount++;

    // Print tag line packet
    out.print(packet.getStringMessage() + "\r\n");

    // Count bytes
    bytes += packet.getStringMessage().length() + 2;
    currentFileBytes += packet.getStringMessage().length() + 2;

    // Maybe print parsed
    if (dumpParsed) {
      if (timestamp != null) {
        out.println("+ timetamp " + timestampFormat.format(timestamp));
      }
      if (vdm.getTags() != null) {
        for (IProprietaryTag tag : vdm.getTags()) {
          out.println("+ " + tag.toString());
        }
      }
      AisMessage aisMessage = packet.tryGetAisMessage();
      if (aisMessage != null) {
        out.println("+ " + aisMessage.toString());
      } else {
        out.println("+ AIS message could not be parsed");
      }

      // Check for binary message
      if (aisMessage instanceof AisBinaryMessage) {
        AisBinaryMessage binaryMessage = (AisBinaryMessage) aisMessage;
        try {
          AisApplicationMessage appMessage = binaryMessage.getApplicationMessage();
          out.println(appMessage);
        } catch (SixbitException e) {
        }
      }
      out.println("---------------------------");
    }

    // Maybe time for new outfile
    if (splitSize != null && currentFileBytes >= splitSize) {
      out.close();
      out = null;
      currentFileBytes = 0;
    }
  }
Exemplo n.º 4
0
  @Override
  protected void run(Injector injector) throws Exception {
    if (filename == null && hostPort == null && (dir == null || name == null)) {
      usage();
      System.exit(-1);
    }

    // Create reader
    AisReader aisReader;
    if (filename != null) {
      aisReader = AisReaders.createReaderFromFile(filename);
    } else if (hostPort != null) {
      AisTcpReader rrAisReader = AisReaders.createReader(hostPort);
      rrAisReader.setTimeout(timeout);
      aisReader = rrAisReader;
    } else {
      aisReader = AisReaders.createDirectoryReader(dir, name, recursive);
    }

    runtime *= 1000;

    // Add times
    filter.parseStartAndEnd(starttimeStr, endtimeStr);

    // Add base stations
    filter.parseBaseStations(baseStations);

    // Add countries
    filter.parseCountries(countries);

    // Add regions
    filter.parseRegions(regions);

    // Output stream
    if (outFile == null) {
      out = System.out;
    }

    // Message handler
    // Add filters
    // Maybe insert downsampling filter
    if (downsampleRate > 0) {
      filters.add(new ReplayDownSampleFilter(downsampleRate));
    }
    if (doubletFiltering) {
      filters.add(new ReplayDuplicateFilter());
    }
    if (expression != null) {
      filters.add(new ExpressionFilter(expression));
    }
    if (geometry != null) {
      LocationFilter locationFilter = new LocationFilter();
      Area a = getGeometry(geometry);
      locationFilter.addFilterGeometry(e -> a.contains(e));
      filters.add(locationFilter);
    }

    // Register handler
    aisReader.registerPacketHandler(this);

    // Start reader thread
    long start = System.currentTimeMillis();
    aisReader.start();

    while (true) {
      Thread.sleep(500);
      if (aisReader.getStatus() == Status.DISCONNECTED) {
        break;
      }
      if (runtime > 0 && System.currentTimeMillis() - start > runtime) {
        stop = true;
        aisReader.stopReader();
        break;
      }
    }
  }