in progress
[jalview.git] / forester / java / src / org / forester / msa / ResampleableMsa.java
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.
4 //
5 // Copyright (C) 2010 Christian M Zmasek
6 // Copyright (C) 2010 Sanford-Burnham Medical Research Institute
7 // All rights reserved
8 //
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.
13 //
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.
18 //
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
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25
26 package org.forester.msa;
27
28 public final class ResampleableMsa extends BasicMsa {
29
30     private int[] _resampled_column_positions = null;
31
32     public ResampleableMsa( final BasicMsa msa ) {
33         super( msa );
34     }
35
36     public void resample( final int[] resampled_column_positions ) {
37         if ( resampled_column_positions.length != getLength() ) {
38             throw new IllegalArgumentException( "illegal attempt to use " + resampled_column_positions.length
39                     + " resampled column positions on msa of length " + getLength() );
40         }
41         _resampled_column_positions = resampled_column_positions;
42     }
43
44     @Override
45     public char getResidueAt( final int row, final int col ) {
46         if ( _resampled_column_positions != null ) {
47             return super.getResidueAt( row, _resampled_column_positions[ col ] );
48         }
49         return super.getResidueAt( row, col );
50     }
51
52     @Override
53     public void setResidueAt( final int row, final int col, final char residue ) {
54         throw new NoSuchMethodError( "illegal attempt to set residue in resampleable msa" );
55     }
56 }