inprogress
[jalview.git] / forester / java / src / org / forester / msa / MsaMethods.java
index ee9338b..ac6cb1f 100644 (file)
@@ -21,7 +21,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 //
 // Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
 
 package org.forester.msa;
 
@@ -65,13 +65,26 @@ public final class MsaMethods {
     public static int calcGapSumPerColumn( final Msa msa, final int col ) {
         int gap_rows = 0;
         for( int j = 0; j < msa.getNumberOfSequences(); ++j ) {
-            if ( msa.getResidueAt( j, col ) == Sequence.GAP ) {
+            if ( msa.isGapAt( j, col ) ) {
                 gap_rows++;
             }
         }
         return gap_rows;
     }
 
+    final public static Msa removeSequence( final Msa msa, final String to_remove_id ) {
+        final List<Sequence> seqs = new ArrayList<Sequence>();
+        for( int row = 0; row < msa.getNumberOfSequences(); ++row ) {
+            if ( !to_remove_id.equals( msa.getIdentifier( row ) ) ) {
+                seqs.add( BasicSequence.copySequence( msa.getSequence( row ) ) );
+            }
+        }
+        if ( seqs.size() < 1 ) {
+            return null;
+        }
+        return BasicMsa.createInstance( seqs );
+    }
+
     final public static Msa removeSequences( final Msa msa, final List<String> to_remove_ids ) {
         final List<Sequence> seqs = new ArrayList<Sequence>();
         for( int row = 0; row < msa.getNumberOfSequences(); ++row ) {
@@ -162,11 +175,13 @@ public final class MsaMethods {
     public static SortedMap<Character, Integer> calculateResidueDestributionPerColumn( final Msa msa, final int column ) {
         final SortedMap<Character, Integer> map = new TreeMap<Character, Integer>();
         for( final Character r : msa.getColumnAt( column ) ) {
-            if ( !map.containsKey( r ) ) {
-                map.put( r, 1 );
-            }
-            else {
-                map.put( r, map.get( r ) + 1 );
+            if ( r != Sequence.GAP ) {
+                if ( !map.containsKey( r ) ) {
+                    map.put( r, 1 );
+                }
+                else {
+                    map.put( r, map.get( r ) + 1 );
+                }
             }
         }
         return map;