X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FDna.java;h=5dcf212299933186ca544d7d23777cbbfeff9d9f;hb=4b7d3640209c4434d569c746672cf9eed4250ace;hp=2ad8487bcdec37ef0e84d4e83d68f1e573663155;hpb=948bd3bcbacc509da0cefaae3eedd97300a6ccce;p=jalview.git diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index 2ad8487..5dcf212 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -163,7 +163,8 @@ public class Dna * @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); @@ -194,10 +195,11 @@ public class Dna } /** + * Translates cDNA using the specified code table * * @return */ - public AlignmentI translateCdna() + public AlignmentI translateCdna(GeneticCodeI codeTable) { AlignedCodonFrame acf = new AlignedCodonFrame(); @@ -209,7 +211,7 @@ public class Dna for (s = 0; s < sSize; s++) { SequenceI newseq = translateCodingRegion(selection.get(s), - seqstring[s], acf, pepseqs); + seqstring[s], acf, pepseqs, codeTable); if (newseq != null) { @@ -252,29 +254,30 @@ public class Dna for (int gd = 0; gd < selection.length; gd++) { SequenceI dna = selection[gd]; - DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(), + List dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(), jalview.datamodel.DBRefSource.DNACODINGDBS); if (dnarefs != null) { // intersect with pep List mappedrefs = new ArrayList<>(); - DBRefEntry[] refs = dna.getDBRefs(); - for (int d = 0; d < refs.length; d++) + List refs = dna.getDBRefs(); + for (int d = 0, nd = refs.size(); d < nd; d++) { - if (refs[d].getMap() != null && refs[d].getMap().getMap() != null - && refs[d].getMap().getMap().getFromRatio() == 3 - && refs[d].getMap().getMap().getToRatio() == 1) + DBRefEntry ref = refs.get(d); + if (ref.getMap() != null && ref.getMap().getMap() != null + && ref.getMap().getMap().getFromRatio() == 3 + && ref.getMap().getMap().getToRatio() == 1) { - mappedrefs.add(refs[d]); // add translated protein maps + mappedrefs.add(ref); // add translated protein maps } } - dnarefs = mappedrefs.toArray(new DBRefEntry[mappedrefs.size()]); - for (int d = 0; d < dnarefs.length; d++) + dnarefs = mappedrefs;// .toArray(new DBRefEntry[mappedrefs.size()]); + for (int d = 0, nd = dnarefs.size(); d < nd; d++) { - Mapping mp = dnarefs[d].getMap(); + Mapping mp = dnarefs.get(d).getMap(); if (mp != null) { - for (int vc = 0; vc < viscontigs.length; vc += 2) + for (int vc = 0, nv = viscontigs.length; vc < nv; vc += 2) { int[] mpr = mp.locateMappedRange(viscontigs[vc], viscontigs[vc + 1]); @@ -429,11 +432,12 @@ public class Dna * @param acf * Definition of global ORF alignment reference frame * @param proteinSeqs + * @param codeTable * @return sequence ready to be added to alignment. */ protected SequenceI translateCodingRegion(SequenceI selection, String seqstring, AlignedCodonFrame acf, - List proteinSeqs) + List proteinSeqs, GeneticCodeI codeTable) { List skip = new ArrayList<>(); int[] skipint = null; @@ -468,7 +472,7 @@ public class Dna */ AlignedCodon alignedCodon = new AlignedCodon(cdp[0], cdp[1], cdp[2]); - String aa = ResidueProperties.codonTranslate(new String(codon)); + String aa = codeTable.translate(new String(codon)); rf = 0; final String gapString = String.valueOf(gapChar); if (aa == null) @@ -796,28 +800,29 @@ public class Dna private static void transferCodedFeatures(SequenceI dna, SequenceI pep, MapList map) { - DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(), - DBRefSource.DNACODINGDBS); - if (dnarefs != null) - { - // intersect with pep - for (int d = 0; d < dnarefs.length; d++) - { - Mapping mp = dnarefs[d].getMap(); - if (mp != null) - { - } - } - } + // BH 2019.01.25 nop? + // List dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(), + // DBRefSource.DNACODINGDBS); + // if (dnarefs != null) + // { + // // intersect with pep + // for (int d = 0, nd = dnarefs.size(); d < nd; d++) + // { + // Mapping mp = dnarefs.get(d).getMap(); + // if (mp != null) + // { + // } + // } + // } for (SequenceFeature sf : dna.getFeatures().getAllFeatures()) { - 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)) - { - } } + } } }