tests for jalview.analysis.AlignSeq
authorjprocter <jprocter@compbio.dundee.ac.uk>
Sat, 17 Nov 2012 18:50:34 +0000 (18:50 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Sat, 17 Nov 2012 18:50:34 +0000 (18:50 +0000)
test/jalview/analysis/TestAlignSeq.java [new file with mode: 0644]

diff --git a/test/jalview/analysis/TestAlignSeq.java b/test/jalview/analysis/TestAlignSeq.java
new file mode 100644 (file)
index 0000000..59740df
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package jalview.analysis;
+
+import static org.junit.Assert.*;
+import jalview.datamodel.Mapping;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test the alignment -> Mapping routines
+ * @author jimp
+ *
+ */
+public class TestAlignSeq
+{
+
+  SequenceI s1,s2,s3;
+  /**
+   * @throws java.lang.Exception
+   */
+  @Before
+  public void setUp() throws Exception
+  {
+    s1 = new Sequence("Seq1","ASDFAQQQRRRSSS");
+    s1.setStart(3);
+    s2 = new Sequence("Seq2","ASDFA");
+    s2.setStart(5);
+    s3 = new Sequence("Seq1","SDFAQQQSSS");
+
+  }
+
+  @Test
+  /**
+   * simple test that mapping from alignment corresponds identical positions.
+   */
+  public void TestGetMappingForS1()
+  {
+    jalview.analysis.AlignSeq as = jalview.analysis.AlignSeq.doGlobalNWAlignment(s1, s2, AlignSeq.PEP);
+    System.out.println("s1: "+as.getAStr1());
+    System.out.println("s2: "+as.getAStr2());
+    
+    Mapping s1tos2=as.getMappingFromS1(false);
+    System.out.println(s1tos2.getMap().toString());
+    for (int i=s2.getStart();i<s2.getEnd();i++)
+    {
+      System.out.println("Position in s2: "+i +" maps to position in s1: "+s1tos2.getPosition(i));
+      assertTrue("",s2.getCharAt(i)==s1.getCharAt(s1tos2.getPosition(i)));
+    }
+  }
+
+}