All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.bio.seq.pattern.SeqPatternMatcher Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.bio.seq.pattern;

import java.util.ArrayList;
import java.util.List;

import com.hfg.bio.seq.BioSequence;
import com.hfg.bio.seq.SeqLocation;

public interface SeqPatternMatcher
{
   public S getTarget();


   //---------------------------------------------------------------------------
   public default T find()
   {
      return find(null);
   }

   public T find(SeqLocation inSeqLocation);

   //---------------------------------------------------------------------------
   public default List findAll()
   {
      return findAll(new SeqLocation(1, getTarget().length()));
   }

   //---------------------------------------------------------------------------
   public default List findAll(SeqLocation inSeqLocation)
   {
      List matches = null;

      SeqLocation seqLocation = inSeqLocation.clone();

      T match;
      while ((match = find(seqLocation)) != null)
      {
         if (null == matches)
         {
            matches = new ArrayList<>();
         }

         matches.add(match);

         seqLocation.setStart(match.getSeqLocation().getStart() + 1);

         if (seqLocation.length() <= 0)
         {
            break;
         }
      }

      return matches;
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy