/**
* Data structure to hold and manipulate a multiple sequence alignment
- */
-/**
- * @author JimP
*
+ * @author JimP
*/
public class Alignment implements AlignmentI
{
+ private static final SequenceGroup[] NO_GROUPS = new SequenceGroup[0];
+
private Alignment dataset;
private List<SequenceI> sequences;
private boolean nucleotide = true;
+ private List<AlignedCodonFrame> codonFrameList;
+
+ /*
+ * persistent object to hold result of findAllGroups(SequenceI)
+ */
+ private List<SequenceGroup> groupsForSequence = new ArrayList<>();
+
public boolean hasRNAStructure = false;
public AlignmentAnnotation[] annotations;
public Hashtable alignmentProperties;
- private List<AlignedCodonFrame> codonFrameList;
-
private void initAlignment(SequenceI[] seqs)
{
groups = Collections.synchronizedList(new ArrayList<SequenceGroup>());
/**
* Make a new alignment from an array of SeqCigars
*
- * @param seqs
- * SeqCigar[]
+ * @param alseqs
*/
public Alignment(SeqCigar[] alseqs)
{
@Override
public SequenceGroup[] findAllGroups(SequenceI s)
{
- ArrayList<SequenceGroup> temp = new ArrayList<>();
-
synchronized (groups)
{
int gSize = groups.size();
+ if (gSize == 0)
+ {
+ return NO_GROUPS;
+ }
+ groupsForSequence.clear();
for (int i = 0; i < gSize; i++)
{
SequenceGroup sg = groups.get(i);
if (sg.getSequences().contains(s))
{
- temp.add(sg);
+ groupsForSequence.add(sg);
}
}
}
- SequenceGroup[] ret = new SequenceGroup[temp.size()];
- return temp.toArray(ret);
+ SequenceGroup[] ret = new SequenceGroup[groupsForSequence.size()];
+ return groupsForSequence.toArray(ret);
}
/** */