X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=testsrc%2Fcompbio%2Fdata%2Fsequence%2FSequenceUtilTester.java;h=720037baa52a734b5baf94ec4654267d14394c8e;hb=fab6bab770b548a0c99ed6f5dfb46f5aa99f67c7;hp=3dd09efcde52c8ed7d276644682e82df6fba803d;hpb=535359a3d592ee41bda72e7356f0181f6cee9d07;p=jabaws.git diff --git a/testsrc/compbio/data/sequence/SequenceUtilTester.java b/testsrc/compbio/data/sequence/SequenceUtilTester.java index 3dd09ef..720037b 100644 --- a/testsrc/compbio/data/sequence/SequenceUtilTester.java +++ b/testsrc/compbio/data/sequence/SequenceUtilTester.java @@ -1,21 +1,16 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * This library is free software; you can redistribute it and/or modify it under the terms of the - * Apache License version 2 as published by the Apache Software Foundation - * - * This library 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 Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. +/* + * Copyright (c) 2009 Peter Troshin JAva Bioinformatics Analysis Web Services + * (JABAWS) @version: 1.0 This library is free software; you can redistribute it + * and/or modify it under the terms of the Apache License version 2 as published + * by the Apache Software Foundation This library 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 + * Apache License for more details. A copy of the license is in + * apache_license.txt. It is also available here: + * @see: http://www.apache.org/licenses/LICENSE-2.0.txt Any republication or + * derived work distributed in source code form must include this copyright and + * license notice. */ - package compbio.data.sequence; import static org.testng.AssertJUnit.assertEquals; @@ -100,7 +95,7 @@ public class SequenceUtilTester { fou.close(); FileOutputStream fou20 = new FileOutputStream( AllTestSuit.TEST_DATA_PATH + "TO1381.fasta20.written"); - SequenceUtil.writeFasta(fou20, fseqs, 20); + SequenceUtil.writeFasta(fou20, fseqs, 21); fou20.close(); } catch (FileNotFoundException e) { @@ -112,4 +107,76 @@ public class SequenceUtilTester { } } + /** + * This test tests the loading of horizontally formatted Jronn output file + */ + @Test + public void loadJronnFile() { + + FileInputStream fio; + try { + fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "jronn.out"); + List aseqs = SequenceUtil.readJRonn(fio); + assertNotNull(aseqs); + assertEquals(aseqs.size(), 3); + AnnotatedSequence aseq = aseqs.get(0); + assertNotNull(aseq); + assertNotNull(aseq.getAnnotation()); + // System.out.println(aseq); + assertEquals(aseq.getAnnotation().length, aseq.getSequence() + .length()); + fio.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (UnknownFileFormatException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } + + } + + enum Trial { + one, two, three + }; + + /** + * This test tests the loading of horizontally formatted Jronn output file + */ + @SuppressWarnings("unchecked") + @Test + public void testMultiAnnotatedSequence() { + + FileInputStream fio; + try { + fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + + "disembl.out"); + List> aseqs = SequenceUtil + .readDisembl(fio); + assertNotNull(aseqs); + + /* + * MultiAnnotatedSequence ma = new MultiAnnotatedSequence(); + * Map> val = ma.getInstance(Trial.class); + * List list = new ArrayList(); list.add(new + * Float(1.2)); list.add(new Double(5.662)); val.put(Trial.one, + * list); val.put(Trial.two, Arrays.asList(6.22f, 1, 37.6f)); + * System.out.println(val); AnnotatedSequence aseq = aseqs.get(0); + */ + fio.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (UnknownFileFormatException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } + + } }