JAL-4366 incomplete test verifying a 3di alignment can be reconstructed for a peptide...
authorJames Procter <j.procter@dundee.ac.uk>
Thu, 11 Jan 2024 14:45:33 +0000 (14:45 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Thu, 11 Jan 2024 14:45:33 +0000 (14:45 +0000)
test/jalview/datamodel/AlignmentTest.java

index 1c27420..28a1ed2 100644 (file)
@@ -38,9 +38,12 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import jalview.analysis.AlignmentGenerator;
+import jalview.analysis.AlignmentUtils;
+import jalview.analysis.CrossRef;
 import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
 import jalview.gui.JvOptionPane;
 import jalview.io.DataSourceType;
+import jalview.io.FastaFile;
 import jalview.io.FileFormat;
 import jalview.io.FileFormatI;
 import jalview.io.FormatAdapter;
@@ -829,6 +832,59 @@ public class AlignmentTest
   }
 
   /**
+   * test mapping between a protein and 3di sequence alignment. Assumes 1:1
+   * @throws IOException
+   */
+  @Test(groups={"Functional"},enabled=true)
+  public void testAlignAs_3di() throws IOException
+  {
+    String protAl = ">1ji5_A\n"
+            + "-----------------------------DQPVLLLLLLQLLLLLVLLLQQLVVCLVQAD\n"
+            + "DPCNVVSNVVSVVSSVVSVVSNVVSQVVCVVVVHHHDDDVSSVVRYPQDHHDPP--DYPL\n"
+            + "RSLVSLLVSLVVVLVSLVVSLVSCVVVVNVVSNVSSVVVSVVSVVSNVVSCVVVVD----\n"
+            + "---------------------------------------------------\n"
+            + ">1jig_A\n"
+            + "---------------------------DALLVVLLLLLLQLLLALVLLLQQLVLCLVLAD\n"
+            + "DPCNVVSNVVSVVVSVVSVVSNVVSQVVCVVSVHHHDDDVSSVVRYPQDHDDSP--DYPL\n"
+            + "RSLVSLLVSLVVLLVSLVVSLVSCVVNVNPVSNVSSVVSSVVSVVSNVVSVVVND-----\n"
+            + "---------------------------------------------------\n"
+            + "\n";
+    String tdiAl = ">1ji5_A\n"
+            + "-----------------------------MNKQVIEVLNKQVADWSVLFTKLHNFHWYVK\n"
+            + "GPQFFTLHEKFEELYTESATHIDEIAERILAIGGKPVATKEYLEISSIQEAAYG--ETAE\n"
+            + "GMVEAIMKDYEMMLVELKKGMEIAQNSDDEMTSDLLLGIYTELEKHAWMLRAFLNQ----\n"
+            + "---------------------------------------------------\n"
+            + ">1jig_A\n"
+            + "---------------------------MSTKTNVVEVLNKQVANWNVLYVKLHNYHWYVT\n"
+            + "GPHFFTLHEKFEEFYNEAGTYIDELAERILALEGKPLATKEYLATSSVNEGTSK--ESAE\n"
+            + "EMVQTLVNDYSALIQELKEGMEVAGEAGDATSADMLLAIHTTLEQHVWMLSAFLK-----\n"
+            + "---------------------------------------------------\n" + "";
+    AlignmentI prot = loadAlignment(protAl, FileFormat.Fasta);
+    ((Alignment) prot).createDatasetAlignment();
+
+    AlignmentI tdi = loadAlignment(tdiAl, FileFormat.Fasta);
+    assertTrue(AlignmentUtils.map3diPeptideToProteinAligment(prot, tdi));
+
+    AlignmentI newProt = new Alignment(
+            new SequenceI[]
+            { prot.getSequenceAt(0).getSubSequence(25, 35),
+                prot.getSequenceAt(1).getSubSequence(35, 45) });
+    newProt.setDataset(prot.getDataset());
+
+    // TODO Find matching tdi sequence and construct alignment mirroring
+    // the protein alignment
+    // Alignment newTdi = new CrossRef(newProt.getSequencesArray(),
+    // newProt.getDataset()).findXrefSequences("", false);
+    //
+    // newTdi.alignAs(newProt);
+    //
+    // System.out.println("newProt - aa\n"+new
+    // FastaFile().print(newProt.getSequencesArray(), true));
+    // System.out.println("newProt - 3di\n"+new
+    // FastaFile().print(newTdi.getSequencesArray(), true));
+
+  }
+  /**
    * Helper method that makes mappings and then aligns the first alignment as
    * the second
    * 
@@ -857,7 +913,7 @@ public class AlignmentTest
 
   /**
    * Helper method to make mappings between sequences, and add the mappings to
-   * the 'mapped from' alignment
+   * the 'mapped from' alignment. If alFrom.isNucleotide() == alTo.isNucleotide() then ratio is always 1:1
    * 
    * @param alFrom
    * @param alTo