From 5504c1347eb582d05ae9086608223209ecb8c13d Mon Sep 17 00:00:00 2001 From: James Procter Date: Thu, 11 Jan 2024 17:16:57 +0000 Subject: [PATCH] JAL-4366 test reconstruction of peptide alignment given 3di alignment and peptide seqs --- test/jalview/datamodel/AlignmentTest.java | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index 28a1ed2..67965c2 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -97,6 +97,28 @@ public class AlignmentTest "GCTCGUCGTACT\n" + ">Seq2Name/60-71\n" + "GGGTCAGGCAGT\n"; + + private static final String AA_SEQS_2 = + ">Seq1Name/5-8\n" + + "K-QY--L\n" + + ">Seq2Name/12-15\n" + + "-R-FP-W-\n"; + private static final String AA_SEQS_2_DS = + ">Seq1Name/5-8\n" + + "KQYL\n" + + ">Seq2Name/12-15\n" + + "RFPW\n"; + private static final String TD_SEQS_2_DS = + ">Seq1Name/5-8\n" + + "NMPR\n" + + ">Seq2Name/12-15\n" + + "VXYA\n"; + private static final String TD_SEQS_2 = + ">Seq1Name/5-8\n" + + "-NMP-R\n" + + ">Seq2Name/12-15\n" + + "VX--YA\n"; + // @formatter:on private AlignmentI al; @@ -778,6 +800,33 @@ public class AlignmentTest assertEquals("-R-F-P-W", al2.getSequenceAt(1).getSequenceAsString()); } + + /** + * Recover protein MSA from tdi msa + * + * @throws IOException + */ + @Test(groups = { "Functional" }) + public void testAlignAs_prot_tdi() throws Exception + { + // see also AlignmentUtilsTests + AlignmentI al1 = loadAlignment(TD_SEQS_2, FileFormat.Fasta); + AlignmentI al2 = loadAlignment(AA_SEQS_2_DS, FileFormat.Fasta); + al1.setDataset(null); + al2.setDataset(null); + AlignmentI al1copy = new Alignment(al1); + AlignmentI al2copy = new Alignment(al2); + AlignmentUtils.map3diPeptideToProteinAligment(al2, al1); + if (al2.getCodonFrames().isEmpty()) {al2.getCodonFrames().addAll(al1.getCodonFrames()); } + else {al1.getCodonFrames().addAll(al2.getCodonFrames()); }; + + ((Alignment) al2).alignAs(al1); + assertEquals("-NMP-R", al1.getSequenceAt(0).getSequenceAsString()); + assertEquals("VX--YA", al1.getSequenceAt(1).getSequenceAsString()); + assertEquals("-KQY-L", al2.getSequenceAt(0).getSequenceAsString()); + assertEquals("RF--PW", al2.getSequenceAt(1).getSequenceAsString()); + + } /** * Test aligning cdna as per protein alignment. * -- 1.7.10.2