Skip to content

Commit 1116677

Browse files
committed
Reverting
1 parent 8c508f8 commit 1116677

3 files changed

Lines changed: 13 additions & 103 deletions

File tree

biojava3-core/src/main/java/org/biojava3/core/sequence/transcription/RNAToAminoAcidTranslator.java

Lines changed: 10 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,11 @@ public class RNAToAminoAcidTranslator extends
6060
private final AminoAcidCompound unknownAminoAcidCompound;
6161
private final AminoAcidCompound methionineAminoAcidCompound;
6262
private final boolean translateNCodons;
63-
6463
// If true, then translation will stop at the first stop codon encountered
6564
// in the reading frame (the stop codon will be included as the last residue
6665
// in the resulting ProteinSequence, unless removed by #trimStops)
6766
private final boolean stopAtStopCodons;
6867

69-
// If true, then translation will not start until the first start codon
70-
// encountered in the reading frame. The start codon will be included as the
71-
// first residue in the resulting ProteinSequence
72-
private final boolean waitForStartCodon;
73-
7468
/**
7569
* @deprecated Retained for backwards compatability, setting
7670
* {@link #stopAtStopCodons} to <code>false</code>
@@ -109,10 +103,8 @@ public RNAToAminoAcidTranslator(
109103
methionineAminoAcidCompound = aminoAcids.getCompoundForString("M");
110104
// Set to false for backwards compatability
111105
stopAtStopCodons = false;
112-
waitForStartCodon = false;
113106
}
114107

115-
@Deprecated
116108
public RNAToAminoAcidTranslator(
117109
SequenceCreatorInterface<AminoAcidCompound> creator,
118110
CompoundSet<NucleotideCompound> nucleotides,
@@ -146,44 +138,6 @@ public RNAToAminoAcidTranslator(
146138
unknownAminoAcidCompound = aminoAcids.getCompoundForString("X");
147139
methionineAminoAcidCompound = aminoAcids.getCompoundForString("M");
148140
this.stopAtStopCodons = stopAtStopCodons;
149-
// Set for backwards compatibility
150-
waitForStartCodon = false;
151-
}
152-
153-
public RNAToAminoAcidTranslator(
154-
SequenceCreatorInterface<AminoAcidCompound> creator,
155-
CompoundSet<NucleotideCompound> nucleotides,
156-
CompoundSet<Codon> codons,
157-
CompoundSet<AminoAcidCompound> aminoAcids, Table table,
158-
boolean trimStops, boolean initMetOnly, boolean translateNCodons,
159-
boolean stopAtStopCodons, boolean waitForStartCodon) {
160-
161-
super(creator, nucleotides, aminoAcids);
162-
this.trimStops = trimStops;
163-
this.initMetOnly = initMetOnly;
164-
this.translateNCodons = translateNCodons;
165-
166-
quickLookup = new HashMap<Table.CaseInsensitiveTriplet, Codon>(codons
167-
.getAllCompounds().size());
168-
aminoAcidToCodon = new HashMap<AminoAcidCompound, List<Codon>>();
169-
170-
List<Codon> codonList = table.getCodons(nucleotides, aminoAcids);
171-
for (Codon codon : codonList) {
172-
quickLookup.put(codon.getTriplet(), codon);
173-
codonArray[codon.getTriplet().intValue()] = codon;
174-
175-
List<Codon> codonL = aminoAcidToCodon.get(codon.getAminoAcid());
176-
if (codonL == null) {
177-
codonL = new ArrayList<Codon>();
178-
aminoAcidToCodon.put(codon.getAminoAcid(), codonL);
179-
}
180-
codonL.add(codon);
181-
182-
}
183-
unknownAminoAcidCompound = aminoAcids.getCompoundForString("X");
184-
methionineAminoAcidCompound = aminoAcids.getCompoundForString("M");
185-
this.stopAtStopCodons = stopAtStopCodons;
186-
this.waitForStartCodon = waitForStartCodon;
187141
}
188142

189143
/**
@@ -203,9 +157,6 @@ public List<Sequence<AminoAcidCompound>> createSequences(
203157

204158
boolean first = true;
205159

206-
// If not waiting for a start codon, start translating immediately
207-
boolean doTranslate = !waitForStartCodon;
208-
209160
for (SequenceView<NucleotideCompound> element : iter) {
210161
AminoAcidCompound aminoAcid = null;
211162

@@ -217,28 +168,19 @@ public List<Sequence<AminoAcidCompound>> createSequences(
217168
Codon target = null;
218169

219170
target = quickLookup.get(triplet);
220-
221-
// Check for a start
222-
if (doTranslate == false && target.isStart()) {
223-
doTranslate = true;
224-
}
225-
226-
if (doTranslate) {
227-
if (target != null)
228-
aminoAcid = target.getAminoAcid();
229-
if (aminoAcid == null && translateNCodons()) {
230-
aminoAcid = unknownAminoAcidCompound;
231-
} else {
232-
if (first && initMetOnly && target.isStart()) {
233-
aminoAcid = methionineAminoAcidCompound;
234-
}
171+
if (target != null)
172+
aminoAcid = target.getAminoAcid();
173+
if (aminoAcid == null && translateNCodons()) {
174+
aminoAcid = unknownAminoAcidCompound;
175+
} else {
176+
if (first && initMetOnly && target.isStart()) {
177+
aminoAcid = methionineAminoAcidCompound;
235178
}
236-
237-
addCompoundsToList(Arrays.asList(aminoAcid), workingList);
238179
}
239180

240-
if (doTranslate && stopAtStopCodons && target.isStop()) {
241-
// Check if we need to stop, but dont stop until started!
181+
addCompoundsToList(Arrays.asList(aminoAcid), workingList);
182+
183+
if (stopAtStopCodons && target.isStop()) {
242184
break;
243185
}
244186

biojava3-core/src/main/java/org/biojava3/core/sequence/transcription/TranscriptionEngine.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,8 @@ public static class Builder {
190190
private boolean trimStop = true;
191191
private boolean translateNCodons = true;
192192
private boolean decorateRna = false;
193-
// Set at false for backwards compatibility
193+
//Set at false for backwards compatibility
194194
private boolean stopAtStopCodons = false;
195-
private boolean waitForStartCodon = false;
196195

197196
/**
198197
* The method to finish any calls to the builder with which returns a
@@ -285,24 +284,12 @@ public Builder translateNCodons(boolean translateNCodons) {
285284
return this;
286285
}
287286

288-
/**
289-
* If set, then the last codon translated in the resulting peptide
290-
* sequence will be the stop codon
291-
*/
287+
/** If set, then the last codon translated in the resulting peptide sequence will be the stop codon */
292288
public Builder stopAtStopCodons(boolean stopAtStopCodons) {
293289
this.stopAtStopCodons = stopAtStopCodons;
294290
return this;
295291
}
296292

297-
/**
298-
* If set, then translation will not start until a start codon is
299-
* encountered
300-
*/
301-
public Builder waitForStartCodon(boolean waitForStartCodon) {
302-
this.waitForStartCodon = waitForStartCodon;
303-
return this;
304-
}
305-
306293
/**
307294
* Performs an optimisation where RNASequences are not translated into
308295
* their own objects but are views onto the base DNA sequence.
@@ -350,8 +337,7 @@ private RNAToAminoAcidTranslator getRnaAminoAcidTranslator() {
350337
return new RNAToAminoAcidTranslator(getProteinCreator(),
351338
getRnaCompounds(), getCodons(), getAminoAcidCompounds(),
352339
getTable(), isTrimStop(), isInitMet(),
353-
isTranslateNCodons(), isStopAtStopCodons(),
354-
isWaitForStartCodon());
340+
isTranslateNCodons(), isStopAtStopCodons());
355341
}
356342

357343
private CompoundSet<Codon> getCodons() {
@@ -400,9 +386,5 @@ private boolean isDecorateRna() {
400386
private boolean isStopAtStopCodons() {
401387
return stopAtStopCodons;
402388
}
403-
404-
private boolean isWaitForStartCodon() {
405-
return waitForStartCodon;
406-
}
407389
}
408390
}

biojava3-core/src/test/java/org/biojava3/core/sequence/TranslationTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,6 @@ public void translateStopAtInternalStops(){
184184
String testpep = volvoxPep.getSequenceAsString().split("\\*")[0];
185185
assertThat("Translation stops at Stop", pep, is(testpep));
186186
}
187-
188-
@Test
189-
public void waitForStartCodon(){
190-
//Should not start translation until a start codon is encountered
191-
TranscriptionEngine e = new TranscriptionEngine.Builder().waitForStartCodon(true).build();
192-
RNASequence rna = new RNASequence("UCCAUGAGC");
193-
String pep = rna.getProteinSequence(e).getSequenceAsString();
194-
assertThat("Translation starts at Start Codon",pep, is("MS"));
195-
196-
//And should start at start of sequence (NB this is implied by success of all other tests)
197-
e = new TranscriptionEngine.Builder().waitForStartCodon(false).build();
198-
pep = rna.getProteinSequence(e).getSequenceAsString();
199-
assertThat("Translation starts at start of sequence", pep, is("SMS"));
200-
}
201187

202188
@Test
203189
public void translateInitMet() {

0 commit comments

Comments
 (0)