2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.io.gff;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertSame;
25 import static org.testng.AssertJUnit.assertTrue;
26 import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
28 import jalview.datamodel.AlignedCodonFrame;
29 import jalview.datamodel.Alignment;
30 import jalview.datamodel.AlignmentI;
31 import jalview.datamodel.Sequence;
32 import jalview.datamodel.SequenceDummy;
33 import jalview.datamodel.SequenceI;
35 import java.io.IOException;
36 import java.util.ArrayList;
37 import java.util.List;
40 import org.testng.annotations.Test;
42 public class InterProScanHelperTest
46 * Test processing one InterProScan GFF line
50 @Test(groups = "Functional")
51 public void testProcessProteinMatch() throws IOException
53 InterProScanHelper testee = new InterProScanHelper();
54 List<SequenceI> newseqs = new ArrayList<SequenceI>();
55 String[] gff = "Submitted\tPfam\tprotein_match\t5\t30\t0\t+\t.\tName=PF12838;Target=Submitted 5 30;signature_desc=4Fe-4S dicluster domain;ID=match$17_5_30"
57 SequenceI seq = new Sequence("Prot1", "PQRASTGKEEDVMIWCHQN");
58 seq.createDatasetSequence();
59 AlignmentI align = new Alignment(new SequenceI[] {});
60 Map<String, List<String>> set = Gff3Helper.parseNameValuePairs(gff[8]);
63 * this should create a mapping from Prot1/5-30 to virtual sequence
64 * match$17_5_30 (added to newseqs) positions 1-26
66 testee.processProteinMatch(set, seq, gff, align, newseqs, false);
67 assertEquals(1, newseqs.size());
68 assertTrue(newseqs.get(0) instanceof SequenceDummy);
69 assertEquals("match$17_5_30", newseqs.get(0).getName());
70 assertEquals(1, align.getCodonFrames().size());
71 AlignedCodonFrame mapping = align.getCodonFrames().iterator().next();
74 * 'dnaseqs' (map from) is here [Prot1]
75 * 'aaseqs' (map to) is here [match$17_5_30]
77 // TODO use more suitable naming in AlignedCodonFrame
78 assertEquals(1, mapping.getAaSeqs().length);
79 assertSame(seq.getDatasetSequence(), mapping.getdnaSeqs()[0]);
80 assertEquals(1, mapping.getdnaSeqs().length);
81 assertSame(newseqs.get(0), mapping.getAaSeqs()[0]);
82 assertEquals(1, mapping.getdnaToProt().length);
83 assertEquals(1, mapping.getdnaToProt()[0].getFromRanges().size());
84 assertArrayEquals(new int[] { 5, 30 }, mapping.getdnaToProt()[0]
85 .getFromRanges().get(0));
86 assertEquals(1, mapping.getdnaToProt()[0].getToRanges().size());
87 assertArrayEquals(new int[] { 1, 26 }, mapping.getdnaToProt()[0]
88 .getToRanges().get(0));