Skip to content

Commit fa82bcb

Browse files
Commented a gotcha (at least, it just got me):
SimpleGapPenalty penalty = new SimpleGapPenalty(); penalty.setOpenPenalty((short) 10); penalty.getOpenPenalty(); // returns -10, not 10
1 parent 84c7237 commit fa82bcb

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

biojava3-alignment/src/main/java/org/biojava3/alignment/SimpleGapPenalty.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,26 @@ public SimpleGapPenalty() {
6565
/**
6666
* Creates a new set of gap penalties.
6767
*
68-
* @param gop the gap open penalty
69-
* @param gep the gap extension penalty
68+
* @param gop the gap open penalty; should be nonnegative
69+
* @param gep the gap extension penalty; should be nonnegative
7070
*/
7171
public SimpleGapPenalty(short gop, short gep) {
7272
this.gop = (short) -Math.abs(gop);
7373
this.gep = (short) -Math.abs(gep);
7474
setType();
7575
}
7676

77+
/**
78+
* <strong>Returns the negative of the extension penalty passed to the constructor.</strong>
79+
*/
7780
@Override
7881
public short getExtensionPenalty() {
7982
return gep;
8083
}
8184

85+
/**
86+
* <strong>Returns the negative of the opening penalty passed to the constructor.</strong>
87+
*/
8288
@Override
8389
public short getOpenPenalty() {
8490
return gop;
@@ -89,12 +95,18 @@ public Type getType() {
8995
return type;
9096
}
9197

98+
/**
99+
* @param gep Should be nonnegative
100+
*/
92101
@Override
93102
public void setExtensionPenalty(short gep) {
94103
this.gep = (short) -Math.abs(gep);
95104
setType();
96105
}
97106

107+
/**
108+
* @param gop Should be nonnegative
109+
*/
98110
@Override
99111
public void setOpenPenalty(short gop) {
100112
this.gop = (short) -Math.abs(gop);

0 commit comments

Comments
 (0)