*/
package jalview.analysis;
+import static org.junit.Assert.assertNotEquals;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
import jalview.datamodel.features.SequenceFeatures;
import jalview.gui.JvOptionPane;
import jalview.io.AppletFormatAdapter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
ArrayList<AlignedCodonFrame> acfs = new ArrayList<>();
acfs.add(acf);
protein.setCodonFrames(acfs);
-
+ Iterator<SequenceI> protseq = protein.getSequences().iterator();
+ for (SequenceI dnaseq:dna.getSequences()) {
+ assertCanResolveProteinCDS(dnaseq,protseq.next(),protein);
+ }
/*
* verify X is included in the aligned proteins, and placed just
* before the first mapped residue
}
/**
+ * assert that we can resolve the protein product in the given alignment given a DNA sequence with CDS mapping
+ * @param dnaseq
+ * @param protein
+ */
+ private void assertCanResolveProteinCDS(SequenceI dnaseq, SequenceI expProtein, AlignmentI protein)
+ {
+ // try a few different methods to check all work
+ SequenceI aprot=null;
+ for (AlignedCodonFrame cf:protein.getCodonFrame(dnaseq))
+ {
+ aprot=cf.getAaForDnaSeq(dnaseq);
+ if (aprot!=null)
+ {
+ assertTrue("getAaForDnaSeq didn't return expected protein sequence",aprot!=expProtein);
+ break;
+ }
+ }
+ assertNotNull("Didn't locate any proteins via AlignmentI.getCodonFrame .. AlignCodonFrame.getAaForDnaSeq", aprot);
+ // try mapping utils -
+ List<AlignedCodonFrame> mu_mappings=MappingUtils.findMappingsForSequence(dnaseq, protein.getCodonFrames());
+ assertNotNull("No mappings found for dnaseq in protein alignment via MappingUtils.findMappingsForSequence",mu_mappings);
+ assertNotEquals("No mappings found for dnaseq in protein alignment via MappingUtils.findMappingsForSequence",0,mu_mappings.size());
+ SequenceI mu_alignedprot=null;
+ List<SequenceToSequenceMapping> foundMap=null;
+ for (AlignedCodonFrame cf:mu_mappings)
+ {
+ foundMap=new ArrayList<>();
+ mu_alignedprot = cf.findAlignedSequence(dnaseq, protein,foundMap);
+ if (mu_alignedprot!=null) {
+ break;
+ }
+ }
+ assertNotNull("Didn't locate proteins via MappingUtils.findMappingsForSequence",mu_alignedprot);
+ assertTrue("findAlignedSequence didn't return expected protein sequence",mu_alignedprot==expProtein);
+ }
+
+ /**
* Tests for the method that maps the subset of a dna sequence that has CDS
* (or subtype) feature - case where the start codon is incomplete.
*/