Skip to content

Commit 38934ac

Browse files
committed
Removing unnecessary casts
1 parent ed95494 commit 38934ac

File tree

33 files changed

+121
-121
lines changed

33 files changed

+121
-121
lines changed

biojava-aa-prop/src/test/java/org/biojava/nbio/aaproperties/PeptidePropertiesImplTest.java

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,48 +51,48 @@ public void testAAComposition() {
5151
//'W', 'C', 'M', 'H', 'Y', 'F', 'Q', 'N', 'I', 'R', 'D', 'P', 'T', 'K', 'E', 'V', 'S', 'G', 'A', 'L'
5252
Map<String, Double> composition = PeptideProperties.getAACompositionString(sequence);
5353
int sequenceLength = sequence.length() - Utils.getNumberOfInvalidChar(sequence, null, true);
54-
assertEquals(2.0/sequenceLength,(double) composition.get("W"), delta);
55-
assertEquals(3.0/sequenceLength,(double) composition.get("C"), delta);
56-
assertEquals(1.0/sequenceLength,(double) composition.get("M"), delta);
57-
assertEquals(1.0/sequenceLength,(double) composition.get("H"), delta);
58-
assertEquals(0.0/sequenceLength,(double) composition.get("Y"), delta);
59-
assertEquals(0.0/sequenceLength,(double) composition.get("F"), delta);
60-
assertEquals(1.0/sequenceLength,(double) composition.get("Q"), delta);
61-
assertEquals(0.0/sequenceLength,(double) composition.get("N"), delta);
62-
assertEquals(0.0/sequenceLength,(double) composition.get("I"), delta);
63-
assertEquals(4.0/sequenceLength,(double) composition.get("R"), delta);
64-
assertEquals(1.0/sequenceLength,(double) composition.get("D"), delta);
65-
assertEquals(1.0/sequenceLength,(double) composition.get("P"), delta);
66-
assertEquals(1.0/sequenceLength,(double) composition.get("T"), delta);
67-
assertEquals(0.0/sequenceLength,(double) composition.get("K"), delta);
68-
assertEquals(1.0/sequenceLength,(double) composition.get("E"), delta);
69-
assertEquals(1.0/sequenceLength,(double) composition.get("V"), delta);
70-
assertEquals(0.0/sequenceLength,(double) composition.get("S"), delta);
71-
assertEquals(1.0/sequenceLength,(double) composition.get("G"), delta);
72-
assertEquals(3.0/sequenceLength,(double) composition.get("A"), delta);
73-
assertEquals(3.0/sequenceLength,(double) composition.get("L"), delta);
54+
assertEquals(2.0/sequenceLength,composition.get("W"), delta);
55+
assertEquals(3.0/sequenceLength,composition.get("C"), delta);
56+
assertEquals(1.0/sequenceLength,composition.get("M"), delta);
57+
assertEquals(1.0/sequenceLength,composition.get("H"), delta);
58+
assertEquals(0.0/sequenceLength,composition.get("Y"), delta);
59+
assertEquals(0.0/sequenceLength,composition.get("F"), delta);
60+
assertEquals(1.0/sequenceLength,composition.get("Q"), delta);
61+
assertEquals(0.0/sequenceLength,composition.get("N"), delta);
62+
assertEquals(0.0/sequenceLength,composition.get("I"), delta);
63+
assertEquals(4.0/sequenceLength,composition.get("R"), delta);
64+
assertEquals(1.0/sequenceLength,composition.get("D"), delta);
65+
assertEquals(1.0/sequenceLength,composition.get("P"), delta);
66+
assertEquals(1.0/sequenceLength,composition.get("T"), delta);
67+
assertEquals(0.0/sequenceLength,composition.get("K"), delta);
68+
assertEquals(1.0/sequenceLength,composition.get("E"), delta);
69+
assertEquals(1.0/sequenceLength,composition.get("V"), delta);
70+
assertEquals(0.0/sequenceLength,composition.get("S"), delta);
71+
assertEquals(1.0/sequenceLength,composition.get("G"), delta);
72+
assertEquals(3.0/sequenceLength,composition.get("A"), delta);
73+
assertEquals(3.0/sequenceLength,composition.get("L"), delta);
7474

7575
Map<String, Double> iComposition = PeptideProperties.getAACompositionString(fullInvalidSequence);
76-
assertEquals(0.0,(double) iComposition.get("W"), delta);
77-
assertEquals(0.0,(double) iComposition.get("C"), delta);
78-
assertEquals(0.0,(double) iComposition.get("M"), delta);
79-
assertEquals(0.0,(double) iComposition.get("H"), delta);
80-
assertEquals(0.0,(double) iComposition.get("Y"), delta);
81-
assertEquals(0.0,(double) iComposition.get("F"), delta);
82-
assertEquals(0.0,(double) iComposition.get("Q"), delta);
83-
assertEquals(0.0,(double) iComposition.get("N"), delta);
84-
assertEquals(0.0,(double) iComposition.get("I"), delta);
85-
assertEquals(0.0,(double) iComposition.get("R"), delta);
86-
assertEquals(0.0,(double) iComposition.get("D"), delta);
87-
assertEquals(0.0,(double) iComposition.get("P"), delta);
88-
assertEquals(0.0,(double) iComposition.get("T"), delta);
89-
assertEquals(0.0,(double) iComposition.get("K"), delta);
90-
assertEquals(0.0,(double) iComposition.get("E"), delta);
91-
assertEquals(0.0,(double) iComposition.get("V"), delta);
92-
assertEquals(0.0,(double) iComposition.get("S"), delta);
93-
assertEquals(0.0,(double) iComposition.get("G"), delta);
94-
assertEquals(0.0,(double) iComposition.get("A"), delta);
95-
assertEquals(0.0,(double) iComposition.get("L"), delta);
76+
assertEquals(0.0,iComposition.get("W"), delta);
77+
assertEquals(0.0,iComposition.get("C"), delta);
78+
assertEquals(0.0,iComposition.get("M"), delta);
79+
assertEquals(0.0,iComposition.get("H"), delta);
80+
assertEquals(0.0,iComposition.get("Y"), delta);
81+
assertEquals(0.0,iComposition.get("F"), delta);
82+
assertEquals(0.0,iComposition.get("Q"), delta);
83+
assertEquals(0.0,iComposition.get("N"), delta);
84+
assertEquals(0.0,iComposition.get("I"), delta);
85+
assertEquals(0.0,iComposition.get("R"), delta);
86+
assertEquals(0.0,iComposition.get("D"), delta);
87+
assertEquals(0.0,iComposition.get("P"), delta);
88+
assertEquals(0.0,iComposition.get("T"), delta);
89+
assertEquals(0.0,iComposition.get("K"), delta);
90+
assertEquals(0.0,iComposition.get("E"), delta);
91+
assertEquals(0.0,iComposition.get("V"), delta);
92+
assertEquals(0.0,iComposition.get("S"), delta);
93+
assertEquals(0.0,iComposition.get("G"), delta);
94+
assertEquals(0.0,iComposition.get("A"), delta);
95+
assertEquals(0.0,iComposition.get("L"), delta);
9696

9797
//Null would be returned for invalid character
9898
assertNotSame(0d, composition.get("Z"));

biojava-alignment/src/main/java/org/biojava/nbio/alignment/routines/AlignerHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@ public static Last setScorePoint(int x, int y, int gep, int sub, int[][][] score
356356
int i = scores[x][y - 1][0] + gep;
357357
int s = scores[x - 1][y - 1][0] + sub;
358358
if (d >= s && d >= i) {
359-
scores[x][y][0] = (int) d;
359+
scores[x][y][0] = d;
360360
return Last.DELETION;
361361
} else if (s >= i) {
362-
scores[x][y][0] = (int) s;
362+
scores[x][y][0] = s;
363363
return Last.SUBSTITUTION;
364364
} else {
365-
scores[x][y][0] = (int) i;
365+
scores[x][y][0] = i;
366366
return Last.INSERTION;
367367
}
368368
}
@@ -416,7 +416,7 @@ public static Last[][] setScoreVector(int x, int xb, int yb, int ye, int gop, in
416416
Last[] insertion = new Last[] { null, null, Last.INSERTION };
417417
for (int y = yb + 1; y <= ye; y++) {
418418
scores[xb][y][0] = scores[xb][y][1] = min;
419-
scores[xb][y][2] = (int) (scores[xb][y - 1][2] + gep);
419+
scores[xb][y][2] = scores[xb][y - 1][2] + gep;
420420
pointers[y] = insertion;
421421
}
422422
} else {
@@ -465,15 +465,15 @@ public static Last[][] setScoreVector(int x, int xb, int yb, int ye, int gep, in
465465
if (x == xb) {
466466
if (startAnchored) {
467467
assert (xb > 0 && yb > 0);
468-
scores[xb][yb][0] = (int) (scores[xb - 1][yb - 1][0] + subs[yb]);
468+
scores[xb][yb][0] = scores[xb - 1][yb - 1][0] + subs[yb];
469469
pointers[yb][0] = Last.SUBSTITUTION;
470470
}
471471
for (int y = yb + 1; y <= ye; y++) {
472-
scores[xb][y][0] = (int) (scores[xb][y - 1][0] + gep);
472+
scores[xb][y][0] = scores[xb][y - 1][0] + gep;
473473
pointers[y][0] = Last.INSERTION;
474474
}
475475
} else {
476-
scores[x][yb][0] = (int) (scores[x - 1][yb][0] + gep);
476+
scores[x][yb][0] = scores[x - 1][yb][0] + gep;
477477
pointers[yb][0] = Last.DELETION;
478478
for (int y = yb + 1; y <= ye; y++) {
479479
pointers[y][0] = setScorePoint(x, y, gep, subs[y], scores);

biojava-alignment/src/main/java/org/biojava/nbio/alignment/template/AbstractPairwiseSequenceAligner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ protected void reset() {
175175
for (C c : target) {
176176
maxt += getSubstitutionMatrix().getValue(c, c);
177177
}
178-
max = (int) Math.max(maxq, maxt);
178+
max = Math.max(maxq, maxt);
179179
score = min = isLocal() ? 0 : (int) (2 * getGapPenalty().getOpenPenalty() + (query.getLength() +
180180
target.getLength()) * getGapPenalty().getExtensionPenalty());
181181
}

biojava-alignment/src/main/java/org/biojava/nbio/alignment/template/AbstractProfileProfileAligner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ protected void reset() {
247247
tfrac[i] = target.getCompoundWeightsAt(i + 1, cslist);
248248
maxt += getSubstitutionScore(tfrac[i], tfrac[i]);
249249
}
250-
max = (int) Math.max(maxq, maxt);
250+
max = Math.max(maxq, maxt);
251251
score = min = isLocal() ? 0 : (int) (2 * getGapPenalty().getOpenPenalty() + (query.getLength() +
252252
target.getLength()) * getGapPenalty().getExtensionPenalty());
253253
}
@@ -265,7 +265,7 @@ private int getSubstitutionScore(float[] qv, float[] tv) {
265265
}
266266
}
267267
}
268-
return (int) Math.round(score);
268+
return Math.round(score);
269269
}
270270

271271
}

biojava-core/src/main/java/org/biojava/nbio/core/alignment/SimpleProfile.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ protected SimpleProfile(AlignedSequence<S, C> query, AlignedSequence<S, C> targe
7575
list.add(target);
7676
list = Collections.unmodifiableList(list);
7777
originals = new ArrayList<S>();
78-
originals.add((S) query.getOriginalSequence());
79-
originals.add((S) target.getOriginalSequence());
78+
originals.add(query.getOriginalSequence());
79+
originals.add(target.getOriginalSequence());
8080
originals = Collections.unmodifiableList(originals);
8181
length = query.getLength();
8282
}
@@ -174,15 +174,15 @@ public SimpleProfile(Collection<AlignedSequence<S,C>> alignedSequences) {
174174
AlignedSequence<S, C> curAlignedSeq = itr.next();
175175
length = curAlignedSeq.getLength();
176176
list.add(curAlignedSeq);
177-
originals.add((S) curAlignedSeq.getOriginalSequence());
177+
originals.add(curAlignedSeq.getOriginalSequence());
178178

179179
while (itr.hasNext()) {
180180
curAlignedSeq = itr.next();
181181
if (curAlignedSeq.getLength() != length) {
182182
throw new IllegalArgumentException("Aligned sequences differ in size");
183183
}
184184
list.add(curAlignedSeq);
185-
originals.add((S) curAlignedSeq.getOriginalSequence());
185+
originals.add(curAlignedSeq.getOriginalSequence());
186186
}
187187
list = Collections.unmodifiableList(list);
188188
originals = Collections.unmodifiableList(originals);

biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private String parse(BufferedReader bufferedReader) {
142142
// Get an ordered list of key->value pairs in array-tuples
143143
do {
144144
section = this.readSection(bufferedReader);
145-
sectionKey = ((String[]) section.get(0))[0];
145+
sectionKey = section.get(0)[0];
146146
if (sectionKey == null) {
147147
//if we reach the end of the file, section contains empty strings
148148
if(section.get(0)[1]==null || section.get(0)[1]=="" ||
@@ -153,7 +153,7 @@ private String parse(BufferedReader bufferedReader) {
153153
}
154154
// process section-by-section
155155
if (sectionKey.equals(LOCUS_TAG)) {
156-
String loc = ((String[]) section.get(0))[1];
156+
String loc = section.get(0)[1];
157157
header = loc;
158158
Matcher m = lp.matcher(loc);
159159
if (m.matches()) {
@@ -183,15 +183,15 @@ private String parse(BufferedReader bufferedReader) {
183183
throw new ParserException("Bad locus line");
184184
}
185185
} else if (sectionKey.equals(DEFINITION_TAG)) {
186-
headerParser.setDescription(((String[]) section.get(0))[1]);
186+
headerParser.setDescription(section.get(0)[1]);
187187
} else if (sectionKey.equals(ACCESSION_TAG)) {
188188
// if multiple accessions, store only first as accession,
189189
// and store rest in annotation
190-
String[] accs = ((String[]) section.get(0))[1].split("\\s+");
190+
String[] accs = section.get(0)[1].split("\\s+");
191191
accession = accs[0].trim();
192192
headerParser.setAccession(accession);
193193
} else if (sectionKey.equals(VERSION_TAG)) {
194-
String ver = ((String[]) section.get(0))[1];
194+
String ver = section.get(0)[1];
195195
Matcher m = vp.matcher(ver);
196196
if (m.matches()) {
197197
String verAcc = m.group(1);
@@ -216,14 +216,14 @@ private String parse(BufferedReader bufferedReader) {
216216
} else if (sectionKey.equals(REFERENCE_TAG)) {
217217
} else if (sectionKey.equals(COMMENT_TAG)) {
218218
// Set up some comments
219-
headerParser.setComment(((String[]) section.get(0))[1]);
219+
headerParser.setComment(section.get(0)[1]);
220220
} else if (sectionKey.equals(FEATURE_TAG)) {
221221
// starting from second line of input, start a new feature whenever we come across
222222
// a key that does not start with /
223223
AbstractFeature gbFeature = null;
224224
for (int i = 1; i < section.size(); i++) {
225-
String key = ((String[]) section.get(i))[0];
226-
String val = ((String[]) section.get(i))[1];
225+
String key = section.get(i)[0];
226+
String val = section.get(i)[1];
227227
if (key.startsWith("/")) {
228228
if (gbFeature == null) {
229229
throw new ParserException("Malformed GenBank file: found a qualifier without feature.");
@@ -285,7 +285,7 @@ private String parse(BufferedReader bufferedReader) {
285285
// and replace '.' and '~' with '-' for our parser.
286286
StringBuffer seq = new StringBuffer();
287287
for (int i = 1; i < section.size(); i++) {
288-
seq.append(((String[]) section.get(i))[1]);
288+
seq.append(section.get(i)[1]);
289289
}
290290
seqData = seq.toString().replaceAll("\\s+", "").replaceAll("[\\.|~]", "-").toUpperCase();
291291
} else if(sectionKey.equals(DBSOURCE)) {
@@ -325,7 +325,7 @@ private List<String[]> readSection(BufferedReader bufferedReader) {
325325
bufferedReader.mark(320);
326326
line = bufferedReader.readLine();
327327
String firstSecKey = section.isEmpty() ? ""
328-
: ((String[]) section.get(0))[0];
328+
: section.get(0)[0];
329329
if (line != null && line.matches("\\p{Space}*")) {
330330
// regular expression \p{Space}* will match line
331331
// having only white space characters

biojava-core/src/main/java/org/biojava/nbio/core/sequence/storage/BitSequenceReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ public C getCompoundAt(int position) {
346346
int arrayIndex = biologicalIndexToArrayIndex(position);
347347
int currentByte = sequence[arrayIndex];
348348
int shiftBy = shiftBy(position);
349-
int shifted = (int) (currentByte >>> shiftBy);
350-
int masked = (int) (shifted & bitMask());
349+
int shifted = currentByte >>> shiftBy;
350+
int masked = shifted & bitMask();
351351

352352
//If we could encode 4 compounds then our max masked value is 3
353353
if (masked > (compoundsPerDatatype() - 1)) {

biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void setProxySequenceReader(SequenceReader<C> proxyLoader) {
142142
}
143143

144144
public SequenceReader<C> getProxySequenceReader() {
145-
return (SequenceReader<C>) sequenceStorage;
145+
return sequenceStorage;
146146
}
147147

148148
/**

biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static int countAT(Sequence<NucleotideCompound> sequence) {
115115
public static <C extends Compound> Map<C, Double> getDistribution(Sequence<C> sequence) {
116116
Map<C, Double> results = new HashMap<C, Double>();
117117
Map<C, Integer> composition = getComposition(sequence);
118-
double length = (double) sequence.getLength();
118+
double length = sequence.getLength();
119119
for (Map.Entry<C, Integer> entry : composition.entrySet()) {
120120
double dist = entry.getValue().doubleValue() / length;
121121
results.put(entry.getKey(), dist);

biojava-core/src/main/java/org/biojava/nbio/core/sequence/transcription/Table.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public int intValue() {
263263

264264
public int compoundToInt(NucleotideCompound c) {
265265
char b = c.getUpperedBase().charAt(0);
266-
return (int)b;
266+
return b;
267267
// int v = -1;
268268
// if('A' == b) {
269269
// v = 1;

0 commit comments

Comments
 (0)