1 // / $Id: ResampleableMsa.java,v 1.3 2010/12/13 18:59:48 cmzmasek Exp $
2 // forester -- software libraries and applications
3 // for genomics and evolutionary biology research.
5 // Copyright (C) 2010 Christian M Zmasek
6 // Copyright (C) 2010 Sanford-Burnham Medical Research Institute
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.msa;
28 import org.forester.sequence.BasicSequence;
29 import org.forester.sequence.Sequence;
31 public final class ResampleableMsa extends BasicMsa {
33 private int[] _resampled_column_positions = null;
35 public ResampleableMsa( final BasicMsa msa ) {
40 final public char getResidueAt( final int row, final int col ) {
41 if ( _resampled_column_positions != null ) {
42 return super.getResidueAt( row, _resampled_column_positions[ col ] );
44 return super.getResidueAt( row, col );
47 final public void resample( final int[] resampled_column_positions ) {
48 if ( resampled_column_positions.length != getLength() ) {
49 throw new IllegalArgumentException( "illegal attempt to use " + resampled_column_positions.length
50 + " resampled column positions on msa of length " + getLength() );
52 _resampled_column_positions = resampled_column_positions;
56 final public void setResidueAt( final int row, final int col, final char residue ) {
57 throw new NoSuchMethodError( "illegal attempt to set residue in resampleable msa" );
61 public Sequence getSequence( final int row ) {
62 return new BasicSequence( getIdentifier( row ), getSequenceAsString( row ).toString(), getType() );