Skip to content

Commit 8f22e0e

Browse files
author
me
committed
automated IDE cleanups and some possible bug fixes
1 parent e9ba77f commit 8f22e0e

File tree

873 files changed

+6921
-7680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

873 files changed

+6921
-7680
lines changed

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/CommandPrompt.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public static void run(String[] args) throws Exception{
9595
/*
9696
* Parse input arguments
9797
*/
98-
List<Character> propertyList = new ArrayList<Character>();
99-
List<Character> specificList = new ArrayList<Character>();
98+
List<Character> propertyList = new ArrayList<>();
99+
List<Character> specificList = new ArrayList<>();
100100
String inputLocation = null;
101101
String outputLocation = null;
102102
String aminoAcidCompositionLocation = null;
@@ -179,15 +179,15 @@ private static LinkedHashMap<String, ProteinSequence> readInputFile(String input
179179
}
180180
LinkedHashMap<String, ProteinSequence> ret;
181181
if ( inputLocation.toLowerCase().contains(".gb")) {
182-
GenbankReader<ProteinSequence, AminoAcidCompound> genbankReader = new GenbankReader<ProteinSequence, AminoAcidCompound>(
183-
inStream, new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(),
182+
GenbankReader<ProteinSequence, AminoAcidCompound> genbankReader = new GenbankReader<>(
183+
inStream, new GenericGenbankHeaderParser<>(),
184184
new ProteinSequenceCreator(set));
185185
ret = genbankReader.process();
186186

187187

188188
} else {
189-
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
190-
inStream, new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
189+
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<>(
190+
inStream, new GenericFastaHeaderParser<>(),
191191
new ProteinSequenceCreator(set));
192192
ret = fastaReader.process();
193193

@@ -198,9 +198,9 @@ private static LinkedHashMap<String, ProteinSequence> readInputFile(String input
198198
public enum PropertyName{MolecularWeight, Absorbance_True, Absorbance_False, ExtinctionCoefficient_True, ExtinctionCoefficient_False,
199199
InstabilityIndex, ApliphaticIndex, AverageHydropathyValue, IsoelectricPoint, NetCharge_pH_7, A, R,
200200
N, D, C, E, Q, G, H, I, L,
201-
K, M, F, P, S, T, W, Y, V};
201+
K, M, F, P, S, T, W, Y, V}
202202

203-
private static void printHeader(PrintStream output, List<Character> propertyList, List<Character> specificList, String delimiter) throws IOException{
203+
private static void printHeader(PrintStream output, List<Character> propertyList, List<Character> specificList, String delimiter) {
204204
int specificCount = 0;
205205
/*
206206
* 1 Molecular weight
@@ -214,7 +214,7 @@ private static void printHeader(PrintStream output, List<Character> propertyList
214214
* 9 Composition of the 20 standard amino acid
215215
* 0 Composition of the specific amino acid
216216
*/
217-
List<String> sList = new ArrayList<String>();
217+
List<String> sList = new ArrayList<>();
218218
sList.add("SequenceName");
219219
for(Character c:propertyList){
220220
switch(c){
@@ -238,7 +238,7 @@ private static void printHeader(PrintStream output, List<Character> propertyList
238238
sList.add(PropertyName.T.toString()); sList.add(PropertyName.W.toString());
239239
sList.add(PropertyName.Y.toString()); sList.add(PropertyName.V.toString());
240240
break;
241-
case '0': sList.add("" + specificList.get(specificCount++)); break;
241+
case '0': sList.add(String.valueOf(specificList.get(specificCount++))); break;
242242
}
243243
}
244244
for(int i = 0; i < sList.size(); i++){
@@ -277,14 +277,11 @@ private static void compute(PrintStream output, String header, String sequence,
277277
IPeptideProperties pp = new PeptidePropertiesImpl();
278278

279279
int specificCount = 0;
280-
List<Double> dList = new ArrayList<Double>();
280+
List<Double> dList = new ArrayList<>();
281281
for(Character c:propertyList){
282282
switch(c){
283283
case '1':
284-
if(aaTable == null)
285-
dList.add(pp.getMolecularWeight(pSequence));
286-
else
287-
dList.add(pp.getMolecularWeight(pSequence));
284+
dList.add(pp.getMolecularWeight(pSequence));
288285
break;
289286
case '2':
290287
dList.add(pp.getAbsorbance(pSequence, true));
@@ -323,7 +320,7 @@ private static void compute(PrintStream output, String header, String sequence,
323320
dList.add(aaCompound2Double.get(Constraints.Y));
324321
dList.add(aaCompound2Double.get(Constraints.V));
325322
break;
326-
case '0': dList.add(pp.getEnrichment(pSequence, aaSet.getCompoundForString("" + specificList.get(specificCount++)))); break;
323+
case '0': dList.add(pp.getEnrichment(pSequence, aaSet.getCompoundForString(String.valueOf(specificList.get(specificCount++))))); break;
327324
}
328325
}
329326
output.print(header.replace(delimiter, "_"));

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/Constraints.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @see IPeptideProperties
4242
*/
4343
public class Constraints {
44-
private static AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
44+
private static final AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
4545
//A, R, N, D, C, E, Q, G, H, I, L, K, M, F, P, S, T, W, Y, V
4646
public static AminoAcidCompound A = aaSet.getCompoundForString("A");
4747
public static AminoAcidCompound R = aaSet.getCompoundForString("R");
@@ -64,14 +64,14 @@ public class Constraints {
6464
public static AminoAcidCompound Y = aaSet.getCompoundForString("Y");
6565
public static AminoAcidCompound V = aaSet.getCompoundForString("V");
6666

67-
public static Map<AminoAcidCompound, Double> aa2ExtinctionCoefficient = new HashMap<AminoAcidCompound, Double>();
68-
public static Map<AminoAcidCompound, Double> aa2MolecularWeight = new HashMap<AminoAcidCompound, Double>();
69-
public static Map<AminoAcidCompound, Double> aa2Hydrophathicity = new HashMap<AminoAcidCompound, Double>();
70-
public static Map<AminoAcidCompound, Double> aa2PKa = new HashMap<AminoAcidCompound, Double>();
71-
public static Map<String, Double> diAA2Instability = new HashMap<String, Double>();
67+
public static Map<AminoAcidCompound, Double> aa2ExtinctionCoefficient = new HashMap<>();
68+
public static Map<AminoAcidCompound, Double> aa2MolecularWeight = new HashMap<>();
69+
public static Map<AminoAcidCompound, Double> aa2Hydrophathicity = new HashMap<>();
70+
public static Map<AminoAcidCompound, Double> aa2PKa = new HashMap<>();
71+
public static Map<String, Double> diAA2Instability = new HashMap<>();
7272

73-
public static Map<AminoAcidCompound, Double> aa2NTerminalPka = new HashMap<AminoAcidCompound, Double>();
74-
public static Map<AminoAcidCompound, Double> aa2CTerminalPka = new HashMap<AminoAcidCompound, Double>();
73+
public static Map<AminoAcidCompound, Double> aa2NTerminalPka = new HashMap<>();
74+
public static Map<AminoAcidCompound, Double> aa2CTerminalPka = new HashMap<>();
7575

7676
static{
7777
initMolecularWeight();
@@ -287,7 +287,7 @@ private static void initInstability(){
287287
SingleLetterAACode[] aa = SingleLetterAACode.values();
288288
for(int i = 0; i < aa.length; i++){
289289
for(int j = 0; j < aa.length; j++){
290-
diAA2Instability.put("" + aa[i] + aa[j], instability[i][j]);
290+
diAA2Instability.put(String.valueOf(aa[i]) + aa[j], instability[i][j]);
291291
}
292292
}
293293
}

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/IPeptideProperties.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public interface IPeptideProperties{
6161
* @return the total molecular weight of sequence + weight of water molecule
6262
* @see ProteinSequence
6363
*/
64-
public double getMolecularWeight(ProteinSequence sequence);
64+
double getMolecularWeight(ProteinSequence sequence);
6565

6666
/**
6767
* Returns the molecular weight of sequence. The sequence argument must be a protein sequence consisting of only non-ambiguous characters.
@@ -80,7 +80,7 @@ public interface IPeptideProperties{
8080
* @throws FileNotFoundException
8181
* thrown if either elementMassFile or aminoAcidCompositionFile are not found
8282
*/
83-
public double getMolecularWeight(ProteinSequence sequence, File aminoAcidCompositionFile) throws JAXBException, FileNotFoundException;
83+
double getMolecularWeight(ProteinSequence sequence, File aminoAcidCompositionFile) throws JAXBException, FileNotFoundException;
8484

8585
/**
8686
* Returns the molecular weight of sequence. The sequence argument must be a protein sequence consisting of only non-ambiguous characters.
@@ -99,7 +99,7 @@ public interface IPeptideProperties{
9999
* @throws FileNotFoundException
100100
* thrown if either elementMassFile or aminoAcidCompositionFile are not found
101101
*/
102-
public double getMolecularWeight(ProteinSequence sequence, File elementMassFile, File aminoAcidCompositionFile)
102+
double getMolecularWeight(ProteinSequence sequence, File elementMassFile, File aminoAcidCompositionFile)
103103
throws JAXBException, FileNotFoundException;
104104

105105
/**
@@ -114,7 +114,7 @@ public double getMolecularWeight(ProteinSequence sequence, File elementMassFile,
114114
* a amino acid composition table obtained by calling IPeptideProperties.obtainAminoAcidCompositionTable
115115
* @return the total molecular weight of sequence + weight of water molecule
116116
*/
117-
public double getMolecularWeightBasedOnXML(ProteinSequence sequence, AminoAcidCompositionTable aminoAcidCompositionTable);
117+
double getMolecularWeightBasedOnXML(ProteinSequence sequence, AminoAcidCompositionTable aminoAcidCompositionTable);
118118

119119
/**
120120
* This method would initialize amino acid composition table based on the input xml files and stores the table for usage in future calls to
@@ -129,7 +129,7 @@ public double getMolecularWeight(ProteinSequence sequence, File elementMassFile,
129129
* @throws FileNotFoundException
130130
* thrown if either elementMassFile or aminoAcidCompositionFile are not found
131131
*/
132-
public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File aminoAcidCompositionFile)
132+
AminoAcidCompositionTable obtainAminoAcidCompositionTable(File aminoAcidCompositionFile)
133133
throws JAXBException, FileNotFoundException;
134134

135135
/**
@@ -146,7 +146,7 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File aminoAcidC
146146
* @throws FileNotFoundException
147147
* thrown if either elementMassFile or aminoAcidCompositionFile are not found
148148
*/
149-
public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMassFile, File aminoAcidCompositionFile)
149+
AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMassFile, File aminoAcidCompositionFile)
150150
throws JAXBException, FileNotFoundException;
151151

152152
/**
@@ -166,7 +166,7 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
166166
* @return the extinction coefficient of sequence
167167
* @see ProteinSequence
168168
*/
169-
public double getExtinctionCoefficient(ProteinSequence sequence, boolean assumeCysReduced);
169+
double getExtinctionCoefficient(ProteinSequence sequence, boolean assumeCysReduced);
170170

171171
/**
172172
* Returns the absorbance (optical density) of sequence. The sequence argument
@@ -182,7 +182,7 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
182182
* @return the absorbance (optical density) of sequence
183183
* @see ProteinSequence
184184
*/
185-
public double getAbsorbance(ProteinSequence sequence, boolean assumeCysReduced);
185+
double getAbsorbance(ProteinSequence sequence, boolean assumeCysReduced);
186186

187187
/**
188188
* Returns the instability index of sequence. The sequence argument must be
@@ -196,7 +196,7 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
196196
* @return the instability index of sequence
197197
* @see ProteinSequence
198198
*/
199-
public double getInstabilityIndex(ProteinSequence sequence);
199+
double getInstabilityIndex(ProteinSequence sequence);
200200

201201
/**
202202
* Returns the apliphatic index of sequence. The sequence argument must be a
@@ -213,7 +213,7 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
213213
* @return the aliphatic index of sequence
214214
* @see ProteinSequence
215215
*/
216-
public double getApliphaticIndex(ProteinSequence sequence);
216+
double getApliphaticIndex(ProteinSequence sequence);
217217

218218
/**
219219
* Returns the average hydropathy value of sequence. The sequence argument
@@ -229,7 +229,7 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
229229
* @return the average hydropathy value of sequence
230230
* @see ProteinSequence
231231
*/
232-
public double getAvgHydropathy(ProteinSequence sequence);
232+
double getAvgHydropathy(ProteinSequence sequence);
233233

234234
/**
235235
* Returns the isoelectric point of sequence. The sequence argument must be
@@ -250,9 +250,9 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
250250
* @return the isoelectric point of sequence
251251
* @see ProteinSequence
252252
*/
253-
public double getIsoelectricPoint(ProteinSequence sequence, boolean useExpasyValues);
253+
double getIsoelectricPoint(ProteinSequence sequence, boolean useExpasyValues);
254254

255-
public double getIsoelectricPoint(ProteinSequence seuqence);
255+
double getIsoelectricPoint(ProteinSequence seuqence);
256256

257257
/**
258258
* Returns the net charge of sequence at pH 7. The sequence argument must be
@@ -274,11 +274,11 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
274274
* @return the net charge of sequence at given pHPoint
275275
* @see ProteinSequence
276276
*/
277-
public double getNetCharge(ProteinSequence sequence, boolean useExpasyValues, double pHPoint);
277+
double getNetCharge(ProteinSequence sequence, boolean useExpasyValues, double pHPoint);
278278

279-
public double getNetCharge(ProteinSequence sequence, boolean useExpasyValues);
279+
double getNetCharge(ProteinSequence sequence, boolean useExpasyValues);
280280

281-
public double getNetCharge(ProteinSequence sequence);
281+
double getNetCharge(ProteinSequence sequence);
282282

283283
/**
284284
* Returns the composition of specified amino acid in the sequence. The
@@ -296,7 +296,7 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
296296
* @see ProteinSequence
297297
* @see AminoAcidCompound
298298
*/
299-
public double getEnrichment(ProteinSequence sequence, AminoAcidCompound aminoAcidCode);
299+
double getEnrichment(ProteinSequence sequence, AminoAcidCompound aminoAcidCode);
300300

301301
/**
302302
* Returns the composition of the 20 standard amino acid in the sequence.
@@ -311,5 +311,5 @@ public AminoAcidCompositionTable obtainAminoAcidCompositionTable(File elementMas
311311
* @see ProteinSequence
312312
* @see AminoAcidCompound
313313
*/
314-
public Map<AminoAcidCompound, Double> getAAComposition(ProteinSequence sequence);
314+
Map<AminoAcidCompound, Double> getAAComposition(ProteinSequence sequence);
315315
}

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/PeptideProperties.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public enum SingleLetterAACode { W, C, M, H, Y, F, Q, N, I, R, D, P, T, K, E, V,
6464
* To initialize the standardAASet
6565
*/
6666
static{
67-
standardAASet = new HashSet<Character>();
67+
standardAASet = new HashSet<>();
6868
for(SingleLetterAACode c:SingleLetterAACode.values()) standardAASet.add(c.toString().charAt(0));
6969
}
7070

@@ -529,9 +529,9 @@ public static final Map<AminoAcidCompound, Double> getAAComposition(String seque
529529
*/
530530
public static final Map<String, Double> getAACompositionString(String sequence){
531531
Map<AminoAcidCompound, Double> aa2Composition = getAAComposition(sequence);
532-
Map<String, Double> aaString2Composition = new HashMap<String, Double>();
533-
for(AminoAcidCompound aaCompound:aa2Composition.keySet()){
534-
aaString2Composition.put(aaCompound.getShortName(), aa2Composition.get(aaCompound));
532+
Map<String, Double> aaString2Composition = new HashMap<>();
533+
for(Map.Entry<AminoAcidCompound, Double> entry : aa2Composition.entrySet()){
534+
aaString2Composition.put(entry.getKey().getShortName(), entry.getValue());
535535
}
536536
return aaString2Composition;
537537
}
@@ -549,9 +549,9 @@ public static final Map<String, Double> getAACompositionString(String sequence){
549549
*/
550550
public static final Map<Character, Double> getAACompositionChar(String sequence){
551551
Map<AminoAcidCompound, Double> aa2Composition = getAAComposition(sequence);
552-
Map<Character, Double> aaChar2Composition = new HashMap<Character, Double>();
553-
for(AminoAcidCompound aaCompound:aa2Composition.keySet()){
554-
aaChar2Composition.put(aaCompound.getShortName().charAt(0), aa2Composition.get(aaCompound));
552+
Map<Character, Double> aaChar2Composition = new HashMap<>();
553+
for(Map.Entry<AminoAcidCompound, Double> entry : aa2Composition.entrySet()){
554+
aaChar2Composition.put(entry.getKey().getShortName().charAt(0), entry.getValue());
555555
}
556556
return aaChar2Composition;
557557
}

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/PeptidePropertiesImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private Map<AminoAcidCompound, Integer> getExtinctAACount(ProteinSequence sequen
210210
}
211211
}
212212
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
213-
Map<AminoAcidCompound, Integer> extinctAA2Count = new HashMap<AminoAcidCompound, Integer>();
213+
Map<AminoAcidCompound, Integer> extinctAA2Count = new HashMap<>();
214214
//Ignore Case is always true
215215
extinctAA2Count.put(aaSet.getCompoundForString("W"), numW + smallW);
216216
extinctAA2Count.put(aaSet.getCompoundForString("C"), (int) (numC + smallC));
@@ -352,16 +352,16 @@ private double getIsoelectricPointInnovagen(ProteinSequence sequence){
352352
{3.55, 7.50, 10.00},// Y
353353
{3.55, 7.50, 0.0}}; // Z
354354

355-
private final double PH_MIN = 0.0; /* minimum pH value */
356-
private final double PH_MAX = 14.0; /* maximum pH value */
357-
private final double MAXLOOP = 2000.0; /* maximum number of iterations */
358-
private final double EPSI = 0.0001; /* desired precision */
355+
private static final double PH_MIN = 0.0; /* minimum pH value */
356+
private static final double PH_MAX = 14.0; /* maximum pH value */
357+
private static final double MAXLOOP = 2000.0; /* maximum number of iterations */
358+
private static final double EPSI = 0.0001; /* desired precision */
359359

360360
private double exp10(double pka){
361361
return Math.pow(10, pka);
362362
}
363363

364-
private double getIsoelectricPointExpasy(String sequence){
364+
private double getIsoelectricPointExpasy(CharSequence sequence){
365365
//
366366
// Compute the amino-acid composition.
367367
//
@@ -390,7 +390,7 @@ private double getIsoelectricPointExpasy(String sequence){
390390
double phMax = PH_MAX;
391391

392392
double phMid = 0.0;
393-
double charge = 1.0;
393+
double charge;
394394
for (int i = 0; i < MAXLOOP && (phMax - phMin) > EPSI; i++){
395395
phMid = phMin + (phMax - phMin) / 2.0;
396396

@@ -532,7 +532,7 @@ private Map<AminoAcidCompound, Integer> getChargedAACount(ProteinSequence sequen
532532
}
533533
}
534534
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
535-
Map<AminoAcidCompound, Integer> chargedAA2Count = new HashMap<AminoAcidCompound, Integer>();
535+
Map<AminoAcidCompound, Integer> chargedAA2Count = new HashMap<>();
536536
chargedAA2Count.put(aaSet.getCompoundForString("K"), numK);
537537
chargedAA2Count.put(aaSet.getCompoundForString("R"), numR);
538538
chargedAA2Count.put(aaSet.getCompoundForString("H"), numH);
@@ -558,7 +558,7 @@ public double getEnrichment(ProteinSequence sequence, AminoAcidCompound aminoAci
558558
@Override
559559
public Map<AminoAcidCompound, Double> getAAComposition(ProteinSequence sequence) {
560560
int validLength = 0;
561-
Map<AminoAcidCompound, Double> aa2Composition = new HashMap<AminoAcidCompound, Double>();
561+
Map<AminoAcidCompound, Double> aa2Composition = new HashMap<>();
562562
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
563563
for(AminoAcidCompound aa:aaSet.getAllCompounds()){
564564
aa2Composition.put(aa, 0.0);

biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/Utils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public final static int getNumberOfInvalidChar(String sequence, Set<Character> c
110110
* a new sequence with all invalid characters being replaced by '-'.
111111
*/
112112
public final static String cleanSequence(String sequence, Set<Character> cSet){
113-
Set<Character> invalidCharSet = new HashSet<Character>();
113+
Set<Character> invalidCharSet = new HashSet<>();
114114
StringBuilder cleanSeq = new StringBuilder();
115115
if(cSet == null) cSet = PeptideProperties.standardAASet;
116116
for(char c:sequence.toCharArray()){
@@ -163,7 +163,7 @@ public static final String checkSequence(String sequence){
163163
* a sequence with no invalid characters.
164164
*/
165165
public static final String checkSequence(String sequence, Set<Character> cSet){
166-
boolean containInvalid = false;
166+
boolean containInvalid;
167167
if(cSet != null){
168168
containInvalid = sequence != null && doesSequenceContainInvalidChar(sequence, cSet);
169169
}else{

0 commit comments

Comments
 (0)