Skip to content

Commit 8a9927c

Browse files
committed
Method for total gapped positions and coverage in aligned sequences
biojava#491
1 parent f57ede4 commit 8a9927c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

biojava-core/src/main/java/org/biojava/nbio/core/alignment/SimpleSequencePair.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,10 @@ public AlignedSequence<S, C> getTarget() {
171171
return getAlignedSequence(2);
172172
}
173173

174+
@Override
175+
public double getPercentageOfIdentity() {
176+
double seqid = getNumIdenticals();
177+
return seqid / getLength();
178+
}
179+
174180
}

biojava-core/src/main/java/org/biojava/nbio/core/alignment/template/SequencePair.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ public interface SequencePair<S extends Sequence<C>, C extends Compound> extends
9696
* @return the number of identical indices
9797
*/
9898
int getNumIdenticals();
99+
100+
/**
101+
* Returns the percentage of identity between the two sequences in the alignment as a fraction between 0 and 1.
102+
* This is equivalent to {@link #getNumIdenticals()} / {@link #getLength()}.
103+
*
104+
* @return the percentage of sequence identity as a fraction in [0,1]
105+
*/
106+
double getPercentageOfIdentity();
99107

100108
/**
101109
* Returns the number of indices for which both the query and target sequences have a similar {@link Compound}.

0 commit comments

Comments
 (0)