com.hfg.bio.seq.pattern.SeqPatternMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
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;
}
}