+ * Updates any empty mappings in the cross-references with one to a compatible
+ * retrieved sequence if found, and adds any new mappings to the
+ * AlignedCodonFrame
+ *
+ * @param dna
+ * @param mapFrom
+ * @param xrefs
+ * @param retrieved
+ * @param acf
+ */
+ static void updateDbrefMappings(boolean dna, SequenceI mapFrom,
+ DBRefEntry[] xrefs, SequenceI[] retrieved, AlignedCodonFrame acf)
+ {
+ SequenceIdMatcher matcher = new SequenceIdMatcher(retrieved);
+ for (DBRefEntry xref : xrefs)
+ {
+ if (!xref.hasMap())
+ {
+ String targetSeqName = xref.getSource() + "|"
+ + xref.getAccessionId();
+ SequenceI[] matches = matcher.findAllIdMatches(targetSeqName);
+ if (matches == null)
+ {
+ return;
+ }
+ for (SequenceI seq : matches)
+ {
+ MapList mapping = null;
+ if (dna)
+ {
+ mapping = AlignmentUtils.mapCdnaToProtein(seq, mapFrom);
+ }
+ else
+ {
+ mapping = AlignmentUtils.mapCdnaToProtein(mapFrom, seq);
+ if (mapping != null)
+ {
+ mapping = mapping.getInverse();
+ }
+ }
+ if (mapping != null)
+ {
+ xref.setMap(new Mapping(seq, mapping));
+ if (dna)
+ {
+ AlignmentUtils.computeProteinFeatures(mapFrom, seq, mapping);
+ }
+ if (dna)
+ {
+ acf.addMap(mapFrom, seq, mapping);
+ }
+ else
+ {
+ acf.addMap(seq, mapFrom, mapping.getInverse());
+ }
+ continue;
+ }
+ }
+ }
+ }
+ }
+
+ /**