import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
-import java.util.Map;
public class Dna
{
* 'final' variables describe the inputs to the translation, which should not
* be modified.
*/
- final private List<SequenceI> selection;
+ private final List<SequenceI> selection;
- final private String[] seqstring;
+ private final String[] seqstring;
- final private int[] contigs;
+ private final List<int[]> contigs;
- final private char gapChar;
+ private final char gapChar;
- final private AlignmentAnnotation[] annotations;
+ private final AlignmentAnnotation[] annotations;
- final private int dnaWidth;
+ private final int dnaWidth;
- final private AlignmentI dataset;
+ private final AlignmentI dataset;
/*
* Working variables for the translation.
* @param viewport
* @param visibleContigs
*/
- public Dna(AlignViewportI viewport, int[] visibleContigs)
+ public Dna(AlignViewportI viewport, List<int[]> visibleContigs)
{
this.selection = Arrays.asList(viewport.getSequenceSelection());
this.seqstring = viewport.getViewAsString(true);
* @param ac2
* @return
*/
- public static final int compareCodonPos(AlignedCodon ac1,
- AlignedCodon ac2)
+ public static final int compareCodonPos(AlignedCodon ac1, AlignedCodon ac2)
{
return comparator.compare(ac1, ac2);
// return jalview_2_8_2compare(ac1, ac2);
int s;
int sSize = selection.size();
- List<SequenceI> pepseqs = new ArrayList<SequenceI>();
+ List<SequenceI> pepseqs = new ArrayList<>();
for (s = 0; s < sSize; s++)
{
SequenceI newseq = translateCodingRegion(selection.get(s),
if (dnarefs != null)
{
// intersect with pep
- List<DBRefEntry> mappedrefs = new ArrayList<DBRefEntry>();
+ List<DBRefEntry> mappedrefs = new ArrayList<>();
DBRefEntry[] refs = dna.getDBRefs();
for (int d = 0; d < refs.length; d++)
{
String seqstring, AlignedCodonFrame acf,
List<SequenceI> proteinSeqs)
{
- List<int[]> skip = new ArrayList<int[]>();
+ List<int[]> skip = new ArrayList<>();
int skipint[] = null;
ShiftList vismapping = new ShiftList(); // map from viscontigs to seqstring
// intervals
- int vc;
- int[] scontigs = new int[contigs.length];
+ int vc = 0;
+ int[] scontigs = new int[contigs.size() * 2];
int npos = 0;
- for (vc = 0; vc < contigs.length; vc += 2)
+ int[] lastregion = null;
+ for (int[] region : contigs)
{
- if (vc == 0)
+ if (lastregion == null)
{
- vismapping.addShift(npos, contigs[vc]);
+ vismapping.addShift(npos, region[0]);
}
else
{
// hidden region
- vismapping.addShift(npos, contigs[vc] - contigs[vc - 1] + 1);
+ vismapping.addShift(npos, region[0] - lastregion[1] + 1);
}
- scontigs[vc] = contigs[vc];
- scontigs[vc + 1] = contigs[vc + 1];
+ lastregion = region;
+
+ scontigs[vc] = region[0];
+ scontigs[vc + 1] = region[1];
+ vc++;
}
// allocate a roughly sized buffer for the protein sequence
*/
MapList map = new MapList(scontigs, new int[] { 1, resSize }, 3, 1);
- transferCodedFeatures(selection, newseq, map, null, null);
+ transferCodedFeatures(selection, newseq, map);
/*
* Construct a dataset sequence for our new peptide.
/**
* Given a peptide newly translated from a dna sequence, copy over and set any
- * features on the peptide from the DNA. If featureTypes is null, all features
- * on the dna sequence are searched (rather than just the displayed ones), and
- * similarly for featureGroups.
+ * features on the peptide from the DNA.
*
* @param dna
* @param pep
* @param map
- * @param featureTypes
- * hash whose keys are the displayed feature type strings
- * @param featureGroups
- * hash where keys are feature groups and values are Boolean objects
- * indicating if they are displayed.
*/
private static void transferCodedFeatures(SequenceI dna, SequenceI pep,
- MapList map, Map<String, Object> featureTypes,
- Map<String, Boolean> featureGroups)
+ MapList map)
{
- SequenceFeature[] sfs = dna.getSequenceFeatures();
- Boolean fgstate;
DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(),
DBRefSource.DNACODINGDBS);
if (dnarefs != null)
}
}
}
- if (sfs != null)
+ for (SequenceFeature sf : dna.getFeatures().getAllFeatures())
{
- for (SequenceFeature sf : sfs)
- {
- fgstate = (featureGroups == null) ? null
- : featureGroups.get(sf.featureGroup);
- if ((featureTypes == null || featureTypes.containsKey(sf.getType()))
- && (fgstate == null || fgstate.booleanValue()))
+ if (FeatureProperties.isCodingFeature(null, sf.getType()))
{
- if (FeatureProperties.isCodingFeature(null, sf.getType()))
+ // if (map.intersectsFrom(sf[f].begin, sf[f].end))
{
- // if (map.intersectsFrom(sf[f].begin, sf[f].end))
- {
- }
}
}
- }
}
}
public AlignmentI reverseCdna(boolean complement)
{
int sSize = selection.size();
- List<SequenceI> reversed = new ArrayList<SequenceI>();
+ List<SequenceI> reversed = new ArrayList<>();
for (int s = 0; s < sSize; s++)
{
SequenceI newseq = reverseSequence(selection.get(s).getName(),