Adding AAConWS
[jabaws.git] / testsrc / compbio / data / sequence / SequenceUtilTester.java
index 3dd09ef..720037b 100644 (file)
@@ -1,21 +1,16 @@
-/* Copyright (c) 2009 Peter Troshin\r
- *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
- * \r
- *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
- *  Apache License version 2 as published by the Apache Software Foundation\r
- * \r
- *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
- *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
- *  License for more details.\r
- * \r
- *  A copy of the license is in apache_license.txt. It is also available here:\r
- * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
- * \r
- * Any republication or derived work distributed in source code form\r
- * must include this copyright and license notice.\r
+/*\r
+ * Copyright (c) 2009 Peter Troshin JAva Bioinformatics Analysis Web Services\r
+ * (JABAWS) @version: 1.0 This library is free software; you can redistribute it\r
+ * and/or modify it under the terms of the Apache License version 2 as published\r
+ * by the Apache Software Foundation This library is distributed in the hope\r
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\r
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * Apache License for more details. A copy of the license is in\r
+ * apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt Any republication or\r
+ * derived work distributed in source code form must include this copyright and\r
+ * license notice.\r
  */\r
-\r
 package compbio.data.sequence;\r
 \r
 import static org.testng.AssertJUnit.assertEquals;\r
@@ -100,7 +95,7 @@ public class SequenceUtilTester {
                        fou.close();\r
                        FileOutputStream fou20 = new FileOutputStream(\r
                                        AllTestSuit.TEST_DATA_PATH + "TO1381.fasta20.written");\r
-                       SequenceUtil.writeFasta(fou20, fseqs, 20);\r
+                       SequenceUtil.writeFasta(fou20, fseqs, 21);\r
                        fou20.close();\r
 \r
                } catch (FileNotFoundException e) {\r
@@ -112,4 +107,76 @@ public class SequenceUtilTester {
                }\r
        }\r
 \r
+       /**\r
+        * This test tests the loading of horizontally formatted Jronn output file\r
+        */\r
+       @Test\r
+       public void loadJronnFile() {\r
+\r
+               FileInputStream fio;\r
+               try {\r
+                       fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "jronn.out");\r
+                       List<AnnotatedSequence> aseqs = SequenceUtil.readJRonn(fio);\r
+                       assertNotNull(aseqs);\r
+                       assertEquals(aseqs.size(), 3);\r
+                       AnnotatedSequence aseq = aseqs.get(0);\r
+                       assertNotNull(aseq);\r
+                       assertNotNull(aseq.getAnnotation());\r
+                       // System.out.println(aseq);\r
+                       assertEquals(aseq.getAnnotation().length, aseq.getSequence()\r
+                                       .length());\r
+                       fio.close();\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (UnknownFileFormatException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
+\r
+       }\r
+\r
+       enum Trial {\r
+               one, two, three\r
+       };\r
+\r
+       /**\r
+        * This test tests the loading of horizontally formatted Jronn output file\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       @Test\r
+       public void testMultiAnnotatedSequence() {\r
+\r
+               FileInputStream fio;\r
+               try {\r
+                       fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH\r
+                                       + "disembl.out");\r
+                       List<MultiAnnotatedSequence<DisemblResultAnnot>> aseqs = SequenceUtil\r
+                                       .readDisembl(fio);\r
+                       assertNotNull(aseqs);\r
+\r
+                       /*\r
+                        * MultiAnnotatedSequence ma = new MultiAnnotatedSequence();\r
+                        * Map<Trial, List<Number>> val = ma.getInstance(Trial.class);\r
+                        * List<Number> list = new ArrayList<Number>(); list.add(new\r
+                        * Float(1.2)); list.add(new Double(5.662)); val.put(Trial.one,\r
+                        * list); val.put(Trial.two, Arrays.asList(6.22f, 1, 37.6f));\r
+                        * System.out.println(val); AnnotatedSequence aseq = aseqs.get(0);\r
+                        */\r
+                       fio.close();\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (UnknownFileFormatException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
+\r
+       }\r
 }\r