_seqs = msa.getNumberOfSequences();
}
+ public short determineMaxIdLength() {
+ short max = 0;
+ for( int row = 0; row < getNumberOfSequences(); ++row ) {
+ final short l = ( short ) getIdentifier( row ).length();
+ if ( l > max ) {
+ max = l;
+ }
+ }
+ 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 void deleteGapOnlyColumns() {
for( int col = getLength() - 1; col >= 0; --col ) {
- if ( MsaMethods.calcGapSumPerColumn( this, col ) == getNumberOfSequences() ) {
+ if ( isAllGap( col ) ) {
deleteColumn( col );
}
}
}
- final public void 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" );
}
+ 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 );
+ if ( return_removed_seq ) {
+ return new BasicSequence( new String( s.getIdentifier() ), sb.toString(), s.getType() );
+ }
+ else {
+ return null;
+ }
}
@Override
return new BasicSequence( getIdentifier( row ), getSequenceAsString( row ).toString(), getType() );
}
+ final public boolean isAllGap( final int col ) {
+ final int m_col = _mapped_col_positions[ col ];
+ for( int j = 0; j < getNumberOfSequences(); ++j ) {
+ if ( super.getResidueAt( _mapped_row_positions[ j ], m_col ) != Sequence.GAP ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
@Override
final public void setIdentifier( final int row, final String id ) {
checkRow( row );