Skip to content

Commit 7f99758

Browse files
committed
Converting some old loggers to slf4j. Clean up.
1 parent ff538b5 commit 7f99758

8 files changed

Lines changed: 97 additions & 112 deletions

File tree

biojava-core/src/main/java/org/biojava/nbio/core/sequence/ExonSequence.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
package org.biojava.nbio.core.sequence;
2424

2525

26-
//import java.util.logging.Logger;
2726

2827
/**
2928
* A gene contains a collection of Exon sequences

biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/FastaReaderTest.java

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.slf4j.Logger;
2828
import org.slf4j.LoggerFactory;
2929

30+
import java.io.IOException;
3031
import java.io.InputStream;
3132
import java.util.LinkedHashMap;
3233
import java.util.logging.Level;
@@ -159,70 +160,54 @@ public void processIntTest() throws Exception {
159160
}
160161

161162
@Test
162-
public void testSmallFasta(){
163+
public void testSmallFasta() throws IOException {
163164

164-
try {
165-
InputStream inStream = this.getClass().getResourceAsStream("/test.fasta");
165+
InputStream inStream = this.getClass().getResourceAsStream("/test.fasta");
166166

167-
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
168-
inStream,
169-
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
170-
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
167+
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
168+
inStream,
169+
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
170+
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
171171

172-
LinkedHashMap<String, ProteinSequence> b;
172+
LinkedHashMap<String, ProteinSequence> b;
173173

174-
int nrSeq = 0;
174+
int nrSeq = 0;
175175

176-
while ((b = fastaReader.process(10)) != null) {
177-
for (String key : b.keySet()) {
178-
nrSeq++;
179-
180-
// #282 would result in an endless loop
181-
// this makes sure it has been fixed.
182-
Assert.assertTrue("Looks like there is a problem with termination of processing of the FASTA file!", nrSeq < 15);
183-
}
176+
while ((b = fastaReader.process(10)) != null) {
177+
for (String key : b.keySet()) {
178+
nrSeq++;
184179

180+
// #282 would result in an endless loop
181+
// this makes sure it has been fixed.
182+
Assert.assertTrue("Looks like there is a problem with termination of processing of the FASTA file!", nrSeq < 15);
185183
}
186-
} catch (Exception ex) {
187-
ex.printStackTrace();
188-
java.util.logging.Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
189184

190-
Assert.fail(ex.getMessage());
191185
}
186+
192187
}
193188

194189

195190
@Test
196-
public void testSmallFasta2(){
197-
198-
try {
199-
InputStream inStream = this.getClass().getResourceAsStream("/test.fasta");
200-
201-
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
202-
inStream,
203-
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
204-
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
191+
public void testSmallFasta2() throws IOException {
205192

193+
InputStream inStream = this.getClass().getResourceAsStream("/test.fasta");
206194

195+
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
196+
inStream,
197+
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
198+
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
207199

208-
int nrSeq = 0;
209200

210-
LinkedHashMap<String, ProteinSequence> b = fastaReader.process();
201+
int nrSeq = 0;
211202

212-
Assert.assertNotNull(b);
203+
LinkedHashMap<String, ProteinSequence> b = fastaReader.process();
213204

214-
// #282 make sure that process() still works
205+
Assert.assertNotNull(b);
215206

216-
Assert.assertTrue(b.keySet().size() == 10);
207+
// #282 make sure that process() still works
217208

209+
Assert.assertEquals(10, b.keySet().size());
218210

219211

220-
221-
} catch (Exception ex) {
222-
ex.printStackTrace();
223-
java.util.logging.Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
224-
225-
Assert.fail(ex.getMessage());
226-
}
227212
}
228213
}

biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/AlternativeAlignment.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131
import org.biojava.nbio.structure.geometry.Matrices;
3232
import org.biojava.nbio.structure.geometry.SuperPositions;
3333
import org.biojava.nbio.structure.jama.Matrix;
34+
import org.slf4j.Logger;
35+
import org.slf4j.LoggerFactory;
3436

3537
import java.io.Serializable;
3638
import java.text.DecimalFormat;
3739
import java.util.List;
38-
import java.util.logging.Logger;
40+
3941

4042
import javax.vecmath.Matrix4d;
4143

@@ -56,42 +58,39 @@
5658
public class AlternativeAlignment implements Serializable{
5759

5860

59-
/**
60-
*
61-
*/
6261
private static final long serialVersionUID = -6226717654562221241L;
6362

64-
int[] idx1;
65-
int[] idx2;
66-
String[] pdbresnum1;
67-
String[] pdbresnum2;
63+
private int[] idx1;
64+
private int[] idx2;
65+
private String[] pdbresnum1;
66+
private String[] pdbresnum2;
6867
//short[] alig1;
6968
//short[] alig2;
7069

71-
int nfrags;
72-
Atom center;
73-
Matrix rot;
74-
Atom tr;
70+
private int nfrags;
71+
private Atom center;
72+
private Matrix rot;
73+
private Atom tr;
7574

7675

7776
// the scores...
78-
int gaps0;
79-
int eqr0;
80-
int rms0;
81-
int joined;
82-
int percId;
83-
int cluster;
84-
float score;
85-
IndexPair[] aligpath;
86-
int fromia;
87-
Matrix currentRotMatrix;
88-
Atom currentTranMatrix;
77+
private int gaps0;
78+
private int eqr0;
79+
private int rms0;
80+
private int joined;
81+
private int percId;
82+
private int cluster;
83+
private float score;
84+
private IndexPair[] aligpath;
85+
private int fromia;
86+
private Matrix currentRotMatrix;
87+
private Atom currentTranMatrix;
8988

90-
double rms;
89+
private double rms;
9190

92-
Matrix distanceMatrix;
91+
private Matrix distanceMatrix;
9392

94-
public static Logger logger = Logger.getLogger("org.biojava.nbio.structure.align");
93+
public static final Logger logger = LoggerFactory.getLogger(AlternativeAlignment.class);
9594

9695

9796
public AlternativeAlignment() {
@@ -319,7 +318,7 @@ public void finish(StrucAligParameters params,Atom[]ca1,Atom[]ca2) throws Struct
319318
rotateShiftAtoms(ca3);
320319

321320
calcScores(ca1,ca2);
322-
logger.fine("eqr " + eqr0 + " " + gaps0 + " " +idx1[0] + " " +idx1[1]);
321+
logger.debug("eqr " + eqr0 + " " + gaps0 + " " +idx1[0] + " " +idx1[1]);
323322

324323
getPdbRegions(ca1,ca2);
325324

@@ -720,10 +719,11 @@ public void setPDBresnum2(String[] pdbresnum2) {
720719

721720

722721

723-
/** Count the number of gaps in an alignment represented by idx1,idx2.
722+
/**
723+
* Count the number of gaps in an alignment represented by idx1,idx2.
724724
*
725-
* @param idx1
726-
* @param idx2
725+
* @param i1
726+
* @param i2
727727
* @return the number of gaps in this alignment
728728
*/
729729
private int count_gaps(int[] i1, int[] i2){

biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/FragmentJoiner.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@
2929
import org.biojava.nbio.structure.align.helper.AlignUtils;
3030
import org.biojava.nbio.structure.align.helper.JointFragments;
3131
import org.biojava.nbio.structure.jama.Matrix;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
3234

3335
import java.io.Serializable;
3436
import java.util.ArrayList;
3537
import java.util.Collections;
3638
import java.util.Comparator;
3739
import java.util.List;
38-
import java.util.logging.Logger;
3940

4041

41-
/** Joins the initial Fragments together to larger Fragments
42+
/**
43+
* Joins the initial Fragments together to larger Fragments
4244
*
4345
* @author Andreas Prlic
4446
* @author Peter Lackner
@@ -47,7 +49,7 @@
4749
*/
4850
public class FragmentJoiner {
4951

50-
public static Logger logger = Logger.getLogger("org.biojava.nbio.structure.align");
52+
public static final Logger logger = LoggerFactory.getLogger(FragmentJoiner.class);
5153

5254
public FragmentJoiner() {
5355
super();
@@ -283,7 +285,8 @@ private double rmsCheck(Atom[] a1, Atom[] a2,List<int[]> idxlist, int p2i, int p
283285
return getRMS(a1,a3,ftmp);
284286
}
285287

286-
/** get the RMS of the JointFragments pair frag
288+
/**
289+
* Get the RMS of the JointFragments pair frag
287290
*
288291
* @param ca1 the array of all atoms of structure1
289292
* @param ca2 the array of all atoms of structure1
@@ -347,11 +350,8 @@ private boolean distanceCheckOk(FragmentPair a, FragmentPair b, float fragCompat
347350

348351
/**
349352
* Calculate the pairwise compatibility of fpairs.
350-
351-
Iterates through a list of fpairs and joins them if
352-
they have compatible rotation and translation parameters.
353-
354-
353+
* Iterates through a list of fpairs and joins them if
354+
* they have compatible rotation and translation parameters.
355355
* @param fraglst FragmentPair[] array
356356
* @param angleDiff angle cutoff
357357
* @param fragCompatDist distance cutoff
@@ -375,10 +375,10 @@ public JointFragments[] frag_pairwise_compat(FragmentPair[] fraglst, int angleDi
375375
List<JointFragments> fll = new ArrayList<JointFragments>();
376376

377377
double adiff = angleDiff * Math.PI / 180d;
378-
logger.finer("addiff" + adiff);
378+
logger.debug("addiff" + adiff);
379379
//distance between two unit vectors with angle adiff
380380
double ddiff = Math.sqrt(2.0-2.0*Math.cos(adiff));
381-
logger.finer("ddiff" + ddiff);
381+
logger.debug("ddiff" + ddiff);
382382

383383
// the fpairs in the flist have to be sorted with respect to their positions
384384

biojava-structure/src/main/java/org/biojava/nbio/structure/rcsb/RCSBDescriptionFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
*/
2020
package org.biojava.nbio.structure.rcsb;
2121

22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
2224
import org.w3c.dom.Element;
2325
import org.w3c.dom.NodeList;
2426

2527
import java.io.IOException;
2628
import java.io.InputStream;
2729
import java.net.URL;
28-
import java.util.logging.Level;
29-
import java.util.logging.Logger;
3030

3131
/**
3232
* Fetches information from <a href="http://www.pdb.org/pdb/software/rest.do#descPDB">RCSB's RESTful Web Service
@@ -54,7 +54,7 @@
5454
*/
5555
public class RCSBDescriptionFactory {
5656

57-
private static final Logger logger = Logger.getLogger(RCSBDescriptionFactory.class.getPackage().getName());
57+
private static final Logger logger = LoggerFactory.getLogger(RCSBDescriptionFactory.class);
5858

5959
private static final String URL_STUB = "http://www.rcsb.org/pdb/rest/describeMol?structureId=";
6060

@@ -69,7 +69,7 @@ public static RCSBDescription get(InputStream stream) {
6969
try {
7070
data = ReadUtils.getNodes(stream);
7171
} catch (IOException e) {
72-
logger.log(Level.WARNING,"Couldn't parse XML", e);
72+
logger.warn("Couldn't parse XML", e);
7373
return null;
7474
}
7575

@@ -112,7 +112,7 @@ public static RCSBDescription get(String pdbId) {
112112
URL url = new URL(URL_STUB + pdbId);
113113
is = url.openConnection().getInputStream();
114114
} catch (IOException e) {
115-
logger.log(Level.WARNING,"Couldn't open connection", e);
115+
logger.warn("Couldn't open connection", e);
116116
return null;
117117
}
118118
return get(is);
@@ -173,7 +173,7 @@ private static void parseChains(RCSBPolymer polymer, String string) {
173173
if (part.length() == 1) {
174174
polymer.addChain(part.charAt(0));
175175
} else {
176-
logger.log(Level.WARNING,"Chain id contained more than one character");
176+
logger.warn("Chain id contained more than one character");
177177
}
178178
}
179179
}

0 commit comments

Comments
 (0)