1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.data.sequence;
\r
21 import static org.testng.AssertJUnit.assertEquals;
\r
22 import static org.testng.AssertJUnit.assertNotNull;
\r
23 import static org.testng.AssertJUnit.assertTrue;
\r
24 import static org.testng.AssertJUnit.fail;
\r
26 import java.io.FileInputStream;
\r
27 import java.io.FileNotFoundException;
\r
28 import java.io.FileOutputStream;
\r
29 import java.io.IOException;
\r
31 import org.testng.annotations.Test;
\r
33 import compbio.metadata.AllTestSuit;
\r
35 public class ClustalAlignmentUtilTester {
\r
38 public void testReadClustalFile() {
\r
40 readWriteClustal("TO1381.aln");
\r
41 } catch (FileNotFoundException e) {
\r
42 e.printStackTrace();
\r
43 fail(e.getMessage());
\r
44 } catch (Exception e) {
\r
45 e.printStackTrace();
\r
46 fail(e.getMessage());
\r
50 static void readWriteClustal(String fname) throws IOException,
\r
51 UnknownFileFormatException {
\r
52 FileInputStream fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH
\r
54 Alignment seqAl = ClustalAlignmentUtil.readClustalFile(fio);
\r
55 assertTrue(seqAl != null);
\r
56 assertTrue(seqAl.getSize() == 3);
\r
57 assertNotNull(seqAl.getSequences());
\r
58 assertEquals(3, seqAl.getSequences().size());
\r
60 // Now try to write the alignment read
\r
61 FileOutputStream os = new FileOutputStream(AllTestSuit.TEST_DATA_PATH
\r
62 + fname + ".written");
\r
63 ClustalAlignmentUtil.writeClustalAlignment(os, seqAl);
\r
67 fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + fname
\r
69 Alignment readseqs = ClustalAlignmentUtil.readClustalFile(fio);
\r
70 assertTrue(readseqs != null);
\r
71 assertTrue(readseqs.getSize() == 3);
\r
76 public void testReadClustalFileShortNames() {
\r
78 readWriteClustal("TO1381s.aln");
\r
79 } catch (FileNotFoundException e) {
\r
80 e.printStackTrace();
\r
81 fail(e.getMessage());
\r
82 } catch (Exception e) {
\r
83 e.printStackTrace();
\r
84 fail(e.getMessage());
\r
89 public void testReadClustalFileLongNames() {
\r
91 readWriteClustal("TO1381L.aln");
\r
92 } catch (FileNotFoundException e) {
\r
93 e.printStackTrace();
\r
94 fail(e.getMessage());
\r
95 } catch (Exception e) {
\r
96 e.printStackTrace();
\r
97 fail(e.getMessage());
\r