import java.util.List;
import org.forester.sequence.BasicSequence;
-import org.forester.sequence.Sequence;
+import org.forester.sequence.MolecularSequence;
public final class DeleteableMsa extends BasicMsa {
_seqs = msa.getNumberOfSequences();
}
+ public final double[] calcGappiness() {
+ final int length = getLength();
+ final double gappiness[] = new double[ length ];
+ final int seqs = getNumberOfSequences();
+ for( int row = 0; row < seqs; ++row ) {
+ for( int col = 0; col < length; ++col ) {
+ }
+ }
+ return gappiness;
+ }
+
+ public static int calcGapSumPerColumn( final Msa msa, final int col ) {
+ int gap_rows = 0;
+ for( int j = 0; j < msa.getNumberOfSequences(); ++j ) {
+ if ( msa.isGapAt( j, col ) ) {
+ gap_rows++;
+ }
+ }
+ return gap_rows;
+ }
+
public short determineMaxIdLength() {
short max = 0;
for( int row = 0; row < getNumberOfSequences(); ++row ) {
}
}
- final public Sequence deleteRow( final String id ) {
+ final public MolecularSequence 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 );
+ MolecularSequence s = null;
+ StringBuilder sb = null;
+ if ( return_removed_seq ) {
+ s = getSequence( row );
+ final char[] x = s.getMolecularSequence();
+ sb = new StringBuilder( x.length );
+ for( final char element : x ) {
+ if ( element != MolecularSequence.GAP ) {
+ sb.append( element );
+ }
+ }
+ }
deleteRow( row );
- return s;
+ if ( return_removed_seq ) {
+ return new BasicSequence( new String( s.getIdentifier() ), sb.toString(), s.getType() );
+ }
+ else {
+ return null;
+ }
}
@Override
}
@Override
- public Sequence getSequence( final int row ) {
+ public MolecularSequence getSequence( final int row ) {
checkRow( row );
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 ) {
+ if ( super.getResidueAt( _mapped_row_positions[ j ], m_col ) != MolecularSequence.GAP ) {
return false;
}
}
final private void deleteColumn( final int col ) {
checkColumn( col );
- for( int c = col; c < _length - 1; ++c ) {
+ for( int c = col; c < ( _length - 1 ); ++c ) {
_mapped_col_positions[ c ] = _mapped_col_positions[ c + 1 ];
}
--_length;
final private void deleteRow( final int row ) {
checkRow( row );
- for( int r = row; r < _seqs - 1; ++r ) {
+ for( int r = row; r < ( _seqs - 1 ); ++r ) {
_mapped_row_positions[ r ] = _mapped_row_positions[ r + 1 ];
}
--_seqs;
}
- public final static DeleteableMsa createInstance( final List<Sequence> seqs ) {
+ public final static DeleteableMsa createInstance( final List<MolecularSequence> seqs ) {
return new DeleteableMsa( ( BasicMsa ) BasicMsa.createInstance( seqs ) );
}