}
return max;
}
-
+
final public void deleteGapColumns( final double max_allowed_gap_ratio ) {
if ( ( max_allowed_gap_ratio < 0 ) || ( max_allowed_gap_ratio > 1 ) ) {
throw new IllegalArgumentException( "max allowed gap ration is out of range: " + max_allowed_gap_ratio );
}
}
- final public Sequence deleteRow( final String id ) {
+ final public Sequence deleteRow( final String id, final boolean return_removed_seq ) {
int row = -1;
for( int r = 0; r < getNumberOfSequences(); ++r ) {
if ( getIdentifier( r ).equals( id ) ) {
if ( row < 0 ) {
throw new IllegalArgumentException( "id [" + id + "] not found" );
}
- final Sequence s = getSequence( row );
+ Sequence s = null;
+ StringBuilder sb = null;
+ if ( return_removed_seq ) {
+ s = getSequence( row );
+ final char[] x = s.getMolecularSequence();
+ sb = new StringBuilder( x.length );
+ for( int i = 0; i < x.length; ++i ) {
+ if ( x[ i ] != Sequence.GAP ) {
+ sb.append( x[ i ] );
+ }
+ }
+ }
deleteRow( row );
- return s;
+ if ( return_removed_seq ) {
+ return new BasicSequence( new String( s.getIdentifier() ), sb.toString(), s.getType() );
+ }
+ else {
+ return null;
+ }
}
@Override