private RawProtein<PrintsRawMatch> processProtein(final RawProtein<PrintsRawMatch> rawProteinUnfiltered){
  final RawProtein<PrintsRawMatch> filteredMatches=new RawProtein<PrintsRawMatch>(rawProteinUnfiltered.getProteinIdentifier());
  final Set<PrintsRawMatch> sortedRawMatches=new TreeSet<PrintsRawMatch>(PrintsFilteredMatchDAOImpl.PRINTS_RAW_MATCH_COMPARATOR);
  sortedRawMatches.addAll(rawProteinUnfiltered.getMatches());
  LOGGER.debug("New 'sortedRawMatches' set contains " + sortedRawMatches.size() + " matches.");
  String currentModelAccession=null;
  Set<PrintsRawMatch> motifMatchesForCurrentModel=new HashSet<PrintsRawMatch>();
  boolean currentMatchesPass=true;
  FingerPRINTSHierarchyDBParser.HierachyDBEntry currentHierachyDBEntry=null;
  final List<String> hierarchyModelIDLimitation=new ArrayList<String>(allPrintsModelIDs);
  for (  PrintsRawMatch rawMatch : sortedRawMatches) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Iterating over sorted raw matches.  Currently looking at protein " + rawProteinUnfiltered.getProteinIdentifier() + " model "+ rawMatch.getModelId());
    }
    if (currentModelAccession == null || !currentModelAccession.equals(rawMatch.getModelId())) {
      if (currentMatchesPass && currentModelAccession != null) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("In processProtein method, calling filterModelMatches for protein " + rawProteinUnfiltered.getProteinIdentifier() + " and model "+ currentModelAccession);
        }
        filteredMatches.addAllMatches(filterModelMatches(motifMatchesForCurrentModel,currentHierachyDBEntry,hierarchyModelIDLimitation));
      }
      currentMatchesPass=true;
      motifMatchesForCurrentModel.clear();
      currentModelAccession=rawMatch.getModelId();
      currentHierachyDBEntry=printsModelData.get(currentModelAccession);
      if (currentHierachyDBEntry == null) {
        throw new IllegalStateException("There is no entry in the FingerPRINThierarchy.db file for model accession " + rawMatch.getModelId());
      }
    }
    if (currentMatchesPass)     currentMatchesPass=rawMatch.getEvalue() <= currentHierachyDBEntry.getEvalueCutoff();
    if (currentMatchesPass)     motifMatchesForCurrentModel.add(rawMatch);
  }
  if (currentMatchesPass) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("In processProtein method, calling filterModelMatches for protein " + rawProteinUnfiltered.getProteinIdentifier() + " and model "+ currentModelAccession);
    }
    filteredMatches.addAllMatches(filterModelMatches(motifMatchesForCurrentModel,currentHierachyDBEntry,hierarchyModelIDLimitation));
  }
  return filteredMatches;
}

private RawProtein < PrintsRawMatch > processProtein ( final RawProtein < PrintsRawMatch > rawProteinUnfiltered ) { final RawProtein < PrintsRawMatch > filteredMatches = new RawProtein < PrintsRawMatch > ( rawProteinUnfiltered . getProteinIdentifier ( ) ) ; final Set < PrintsRawMatch > sortedRawMatches = new TreeSet < PrintsRawMatch > ( PrintsFilteredMatchDAOImpl . PRINTS_RAW_MATCH_COMPARATOR ) ; sortedRawMatches . addAll ( rawProteinUnfiltered . getMatches ( ) ) ; LOGGER . debug ( "New 'sortedRawMatches' set contains " + sortedRawMatches . size ( ) + " matches." ) ; String currentModelAccession = null ; Set < PrintsRawMatch > motifMatchesForCurrentModel = new HashSet < PrintsRawMatch > ( ) ; boolean currentMatchesPass = true ; FingerPRINTSHierarchyDBParser . HierachyDBEntry currentHierachyDBEntry = null ; final List < String > hierarchyModelIDLimitation = new ArrayList < String > ( allPrintsModelIDs ) ; for ( PrintsRawMatch rawMatch : sortedRawMatches ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Iterating over sorted raw matches.  Currently looking at protein " + rawProteinUnfiltered . getProteinIdentifier ( ) + " model " + rawMatch . getModelId ( ) ) ; } if ( currentModelAccession == null || ! currentModelAccession . equals ( rawMatch . getModelId ( ) ) ) { if ( currentMatchesPass && currentModelAccession != null ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "In processProtein method, calling filterModelMatches for protein " + rawProteinUnfiltered . getProteinIdentifier ( ) + " and model " + currentModelAccession ) ; } filteredMatches . addAllMatches ( filterModelMatches ( motifMatchesForCurrentModel , currentHierachyDBEntry , hierarchyModelIDLimitation ) ) ; } currentMatchesPass = true ; motifMatchesForCurrentModel . clear ( ) ; currentModelAccession = rawMatch . getModelId ( ) ; currentHierachyDBEntry = printsModelData . get ( currentModelAccession ) ; if ( currentHierachyDBEntry == null ) { throw new IllegalStateException ( "There is no entry in the FingerPRINThierarchy.db file for model accession " + rawMatch . getModelId ( ) ) ; } } if ( currentMatchesPass ) currentMatchesPass = rawMatch . getEvalue ( ) <= currentHierachyDBEntry . getEvalueCutoff ( ) ; if ( currentMatchesPass ) motifMatchesForCurrentModel . add ( rawMatch ) ; } if ( currentMatchesPass ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "In processProtein method, calling filterModelMatches for protein " + rawProteinUnfiltered . getProteinIdentifier ( ) + " and model " + currentModelAccession ) ; } filteredMatches . addAllMatches ( filterModelMatches ( motifMatchesForCurrentModel , currentHierachyDBEntry , hierarchyModelIDLimitation ) ) ; } return filteredMatches ; }
algorithm : < p / > 1 . filter by evalue < = cutoff 2 . filter by motif count > = min motif count 3 . order by evalue descending 4 . if domain : pass 5 . else if has hierarchy : first ( for protein ) , store hierarchy members , this match passes not first , if in currently stored hierarchy members list , pass and replace hierarchy members list from this one .
