From 320583fd2ac3ea714e6afdac050961978bd34c81 Mon Sep 17 00:00:00 2001 From: James Procter Date: Wed, 12 Jul 2023 08:33:54 +0100 Subject: [PATCH] JAL-4223 - test and patch to ensure numbering matches sequence data from RNAML file --- src/jalview/io/RnamlFile.java | 6 ++++-- test/jalview/io/RNAMLfileTest.java | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/jalview/io/RnamlFile.java b/src/jalview/io/RnamlFile.java index 4d3ddc1..3041a23 100644 --- a/src/jalview/io/RnamlFile.java +++ b/src/jalview/io/RnamlFile.java @@ -160,8 +160,10 @@ public class RnamlFile extends AlignFile } } sqs[i] = new Sequence(id, seq, begin, end); - - sqs[i].setEnd(sqs[i].findPosition(sqs[i].getLength())); + if (seq.length()!=(end-begin+1)) + { + sqs[i].setEnd(sqs[i].findPosition(sqs[i].getLength())); + } String[] annot = new String[rna.length()]; Annotation[] ann = new Annotation[rna.length()]; diff --git a/test/jalview/io/RNAMLfileTest.java b/test/jalview/io/RNAMLfileTest.java index 65cea6f..d2b6f65 100644 --- a/test/jalview/io/RNAMLfileTest.java +++ b/test/jalview/io/RNAMLfileTest.java @@ -20,14 +20,22 @@ */ package jalview.io; +import jalview.datamodel.SequenceI; import jalview.gui.JvOptionPane; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + import java.io.File; +import java.io.IOException; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import fr.orsay.lri.varna.utils.RNAMLParser; +import groovy.lang.Sequence; + public class RNAMLfileTest { @@ -57,4 +65,14 @@ public class RNAMLfileTest } + @Test(groups= {"Functional"}) + public void testRnamlSeqImport() throws IOException + { + RnamlFile parser = new RnamlFile("examples/testdata/7WKP-rna1.xml", DataSourceType.FILE); + SequenceI[] seqs = parser.getSeqsAsArray(); + assertNotNull(seqs); + assertEquals(seqs.length,1); + assertEquals(seqs[0].getEnd()-seqs[0].getStart()+1,seqs[0].getSequence().length); + } + } -- 1.7.10.2