Skip to content

Commit aae8b49

Browse files
committed
Adding a method to check whether an array of sequences contains at least two sequences of an equal length
1 parent d26e861 commit aae8b49

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

biojava-core/src/main/java/org/biojava/nbio/core/util/SequenceTools.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,23 @@ public Sequence<?> getSequenceFromString(String sequence) throws CompoundNotFoun
115115

116116
}
117117

118+
/** A method to check whether an array of sequences contains at least two sequences having an equal length.
119+
*
120+
* @param sequences the array of {@link org.biojava.nbio.core.sequence.ProteinSequence} sequences
121+
* @return true if any two sequences are of an equal length
122+
*/
123+
public static boolean equalLengthSequences(ProteinSequence[] sequences) {
124+
125+
for (int i=0; i<sequences.length-1; i++) {
126+
if (sequences[i]==null)
127+
continue;
128+
for (int j=i+1; j<sequences.length; j++) {
129+
if (sequences[j]==null)
130+
continue;
131+
if (sequences[i].getLength() == sequences[j].getLength())
132+
return true;
133+
}
134+
}
135+
return false;
136+
}
118137
}

0 commit comments

Comments
 (0)