X Tutup
Skip to content

Commit 031f84b

Browse files
author
me
committed
cleanup continued; core and structure unit tests still pass, other modules untested
1 parent 8f22e0e commit 031f84b

File tree

24 files changed

+218
-241
lines changed

24 files changed

+218
-241
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ private String readLine(boolean ignoreLF) throws IOException {
417417
public String readLine() throws IOException {
418418
String line = readLine(false);
419419
if (line != null) {
420-
bytesRead = bytesRead + line.length();
420+
bytesRead += line.length();
421421
}
422422
return line;
423423
}

biojava-core/src/main/java/org/biojava/nbio/core/sequence/location/FuzzyPoint.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,14 @@ public FuzzyPoint(int minPoint, int maxPoint, Resolver<FuzzyPoint> resolver, boo
7070
}
7171

7272
@Override
73-
public Integer getPosition() {
74-
if(super.getPosition() == -1) {
75-
super.setPosition(getResolver().resolve(this));
76-
}
77-
return super.getPosition();
73+
public int getPosition() {
74+
int prevPos = super.getPosition();
75+
if(prevPos == -1) {
76+
int nextPos = getResolver().resolve(this);
77+
super.setPosition(nextPos);
78+
return nextPos;
79+
} else
80+
return prevPos;
7881
}
7982

8083
protected Integer getMax() {
@@ -106,6 +109,7 @@ public Point offset(int distance) {
106109

107110
@Override
108111
public boolean equals(Object obj) {
112+
if (this == obj) return true;
109113
boolean equals = false;
110114
if (Equals.classEqual(this, obj)) {
111115
FuzzyPoint p = (FuzzyPoint) obj;
@@ -130,6 +134,7 @@ public int hashCode() {
130134

131135
@Override
132136
public int compareTo(Point point) {
137+
if (this == point) return 0;
133138
//If we can assign this to a FuzzyPoint then work with a bit more info
134139
if(FuzzyPoint.class.isAssignableFrom(point.getClass())) {
135140
FuzzyPoint fuzzy = (FuzzyPoint)point;

biojava-core/src/main/java/org/biojava/nbio/core/sequence/location/SimplePoint.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public SimplePoint(int position, boolean unknown, boolean uncertain) {
5656
}
5757

5858
@Override
59-
public Integer getPosition() {
59+
public int getPosition() {
6060
return position;
6161
}
6262

@@ -100,6 +100,7 @@ protected int reverse(int position, int length) {
100100

101101
@Override
102102
public boolean equals(Object obj) {
103+
if (this == obj) return true;
103104
boolean equals = false;
104105
if (Equals.classEqual(this, obj)) {
105106
SimplePoint p = (SimplePoint) obj;
@@ -125,8 +126,9 @@ public String toString() {
125126
}
126127

127128
@Override
128-
public int compareTo(Point o) {
129-
return getPosition().compareTo(o.getPosition());
129+
public int compareTo(Point point) {
130+
if (this == point) return 0;
131+
return Integer.compare(getPosition(), point.getPosition());
130132
}
131133

132134
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface Resolver<T extends Point> {
3636
/**
3737
* Returns the position held by this object
3838
*/
39-
Integer getPosition();
39+
int getPosition();
4040

4141
/**
4242
* Returns true if the current position is unknown but is

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public boolean isValidSequence(Sequence<C> sequence) {
166166

167167

168168
@Override
169-
public List<C> getAllCompounds() {
169+
public List<C> getAllCompounds() {
170170
return new ArrayList<>(charSeqToCompound.values());
171171
}
172172

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected void addNucleotideCompound(String base, String complement, String... e
4545
C upper = newNucleotideCompound(base.toUpperCase(), complement.toUpperCase(), upperEquivalents);
4646
C lower = newNucleotideCompound(base.toLowerCase(), complement.toLowerCase(), lowerEquivalents);
4747

48-
List<C> equivalentCompounds = new ArrayList<>();
48+
List<C> equivalentCompounds = new ArrayList<>(equivalents.length*2);
4949

5050
for(int i=0; i<equivalents.length; i++) {
5151
equivalentCompounds.add(getCompoundForString(upperEquivalents[i]));
@@ -68,9 +68,8 @@ protected void calculateIndirectAmbiguities() {
6868

6969
List<NucleotideCompound> ambiguousCompounds = new ArrayList<>();
7070
for(NucleotideCompound compound: getAllCompounds()) {
71-
if (!compound.isAmbiguous()) {
71+
if (!compound.isAmbiguous())
7272
continue;
73-
}
7473
ambiguousCompounds.add(compound);
7574
}
7675

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.biojava.nbio.core.sequence.loader.UniprotProxySequenceReader;
3636
import org.biojava.nbio.core.sequence.location.SequenceLocation;
3737
import org.biojava.nbio.core.sequence.location.SimpleLocation;
38+
import org.biojava.nbio.core.sequence.location.template.AbstractLocation;
3839
import org.biojava.nbio.core.sequence.location.template.Location;
3940
import org.biojava.nbio.core.sequence.reference.AbstractReference;
4041
import org.biojava.nbio.core.sequence.storage.ArrayListSequenceReader;
@@ -126,7 +127,7 @@ public void setProxySequenceReader(SequenceReader<C> proxyLoader) {
126127

127128
if (proxyLoader instanceof FeatureRetriever) {
128129
this.setFeatureRetriever((FeatureRetriever) sequenceStorage);
129-
HashMap<String, ArrayList<AbstractFeature>> ff = getFeatureRetriever().getFeatures();
130+
Map<String, ArrayList<AbstractFeature>> ff = getFeatureRetriever().getFeatures();
130131
for (ArrayList<AbstractFeature> abstractFeatures : ff.values()){
131132
for (AbstractFeature f: abstractFeatures){
132133
this.addFeature(f);
@@ -153,11 +154,7 @@ public SequenceReader<C> getProxySequenceReader() {
153154
* @return the bioBegin
154155
*/
155156
public Integer getBioBegin() {
156-
if (bioBegin == null) {
157-
return 1;
158-
} else {
159-
return bioBegin;
160-
}
157+
return bioBegin == null ? 1 : bioBegin;
161158
}
162159

163160
/**
@@ -171,11 +168,7 @@ public void setBioBegin(Integer bioBegin) {
171168
* @return the bioEnd
172169
*/
173170
public Integer getBioEnd() {
174-
if (bioEnd == null) {
175-
return this.getLength();
176-
} else {
177-
return bioEnd;
178-
}
171+
return bioEnd == null ? this.getLength() : bioEnd;
179172
}
180173

181174
/**
@@ -265,13 +258,10 @@ public void setParentSequence(AbstractSequence<?> parentSequence) {
265258
* @return the source
266259
*/
267260
public String getSource() {
268-
if (source != null) {
261+
if (source != null)
269262
return source;
270-
}
271-
if (parentSequence != null) {
272-
return parentSequence.getSource();
273-
}
274-
return null;
263+
else
264+
return parentSequence != null ? parentSequence.getSource() : null;
275265
}
276266

277267
/**
@@ -353,7 +343,8 @@ public List<FeatureInterface<AbstractSequence<C>, C>> getFeatures(String feature
353343
List<FeatureInterface<AbstractSequence<C>, C>> features = getFeaturesByType(featureType);
354344
if (features != null) {
355345
for (FeatureInterface<AbstractSequence<C>, C> feature : features) {
356-
if (bioSequencePosition >= feature.getLocations().getStart().getPosition() && bioSequencePosition <= feature.getLocations().getEnd().getPosition()) {
346+
AbstractLocation locs = feature.getLocations();
347+
if (bioSequencePosition >= locs.getStart().getPosition() && bioSequencePosition <= locs.getEnd().getPosition()) {
357348
featureHits.add(feature);
358349
}
359350
}

biojava-core/src/test/java/org/biojava/nbio/core/alignment/SimpleAlignedSequenceTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public void testGetAlignmentIndexAtOutOfBounds4() {
117117

118118
@Test
119119
public void testGetEnd() {
120-
assertEquals(global.getEnd().getPosition(), Integer.valueOf(6));
121-
assertEquals(local.getEnd().getPosition(), Integer.valueOf(8));
122-
assertEquals(local2.getEnd().getPosition(), Integer.valueOf(3));
120+
assertEquals(6, global.getEnd().getPosition());
121+
assertEquals(8, local.getEnd().getPosition());
122+
assertEquals(3, local2.getEnd().getPosition());
123123
}
124124

125125
@Test
@@ -211,9 +211,9 @@ public void testGetSequenceIndexAtOutOfBounds4() {
211211

212212
@Test
213213
public void testGetStart() {
214-
assertEquals(global.getStart().getPosition(), Integer.valueOf(2));
215-
assertEquals(local.getStart().getPosition(), Integer.valueOf(1));
216-
assertEquals(local2.getStart().getPosition(), Integer.valueOf(1));
214+
assertEquals(2, global.getStart().getPosition());
215+
assertEquals(1, local.getStart().getPosition());
216+
assertEquals(1, local2.getStart().getPosition());
217217
}
218218

219219
@Test

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/StructureTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,11 @@ public void testCreateVirtualCBAtom(){
222222

223223
if ( g1.getPDBName().equals("GLY")){
224224
if ( g1 instanceof AminoAcid){
225-
try {
226-
Atom cb = Calc.createVirtualCBAtom((AminoAcid)g1);
227-
g1.addAtom(cb);
228-
} catch (StructureException e){
229-
fail ("createVirtualCBAtom failed with " + e.getMessage());
230-
}
225+
// try {
226+
g1.addAtom(Calc.createVirtualCBAtom((AminoAcid)g1));
227+
// } catch (StructureException e){
228+
// fail ("createVirtualCBAtom failed with " + e.getMessage());
229+
// }
231230
}
232231
} else {
233232
fail("the group at position 11 is not a GLY!");

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class MultipleAlignmentJmol extends AbstractAlignmentJmol {
7676

7777
private MultipleAlignment multAln;
7878
private List<Atom[]> transformedAtoms;
79-
private final JCheckBox colorByBlocks;
79+
private JCheckBox colorByBlocks;
8080
private final List<JCheckBox> selectedStructures;
8181

8282
private static final String LIGAND_DISPLAY_SCRIPT = "select ligand; wireframe 40; spacefill 120; color CPK;";

0 commit comments

Comments
 (0)
X Tutup