Skip to content

Commit 0f4983c

Browse files
committed
Fix issue s1319 Declarations should use Java collection interfaces on biojava-core and dependencies
1 parent 51e125b commit 0f4983c

12 files changed

Lines changed: 45 additions & 36 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static void readInputAndGenerateOutput(String outputLocation, List<Chara
8282
else
8383
output = System.out;
8484
printHeader(output, propertyList, specificList, delimiter);
85-
LinkedHashMap<String, ProteinSequence> a = readInputFile(inputLocation, aaTable);
85+
Map<String, ProteinSequence> a = readInputFile(inputLocation, aaTable);
8686
//Need for the last sequence
8787
for(Entry<String, ProteinSequence> entry:a.entrySet()){
8888
compute(output, entry.getValue().getOriginalHeader(), entry.getValue().getSequenceAsString().trim(), delimiter, aaTable, propertyList, specificList,
@@ -169,15 +169,15 @@ public static void run(String[] args) throws Exception{
169169
readInputAndGenerateOutput(outputLocation, propertyList, specificList, delimiter, inputLocation, aaTable, decimalPlace);
170170
}
171171

172-
private static LinkedHashMap<String, ProteinSequence> readInputFile(String inputLocation, AminoAcidCompositionTable aaTable) throws Exception{
172+
private static Map<String, ProteinSequence> readInputFile(String inputLocation, AminoAcidCompositionTable aaTable) throws Exception{
173173
FileInputStream inStream = new FileInputStream(inputLocation);
174174
CompoundSet<AminoAcidCompound> set;
175175
if(aaTable == null){
176176
set = CaseFreeAminoAcidCompoundSet.getAminoAcidCompoundSet();
177177
}else{
178178
set = aaTable.getAminoAcidCompoundSet();
179179
}
180-
LinkedHashMap<String, ProteinSequence> ret;
180+
Map<String, ProteinSequence> ret;
181181
if ( inputLocation.toLowerCase().contains(".gb")) {
182182
GenbankReader<ProteinSequence, AminoAcidCompound> genbankReader = new GenbankReader<>(
183183
inStream, new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(),

‎biojava-alignment/src/main/java/demo/DemoDistanceTree.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.InputStream;
2424
import java.util.LinkedHashMap;
25+
import java.util.Map;
2526

2627
import org.biojava.nbio.core.alignment.matrices.SubstitutionMatrixHelper;
2728
import org.biojava.nbio.core.alignment.template.SubstitutionMatrix;
@@ -64,7 +65,7 @@ public static void main(String[] args) throws Exception {
6465
new ProteinSequenceCreator(AminoAcidCompoundSet
6566
.getAminoAcidCompoundSet()));
6667

67-
LinkedHashMap<String, ProteinSequence> proteinSequences =
68+
Map<String, ProteinSequence> proteinSequences =
6869
fastaReader.process();
6970

7071
inStream.close();

‎biojava-alignment/src/test/java/org/biojava/nbio/phylo/TestForesterWrapper.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.InputStream;
2525
import java.io.OutputStream;
2626
import java.util.LinkedHashMap;
27+
import java.util.Map;
2728

2829
import org.biojava.nbio.core.sequence.MultipleSequenceAlignment;
2930
import org.biojava.nbio.core.sequence.ProteinSequence;
@@ -61,7 +62,7 @@ public void testMSAconversion() throws Exception {
6162
new ProteinSequenceCreator(AminoAcidCompoundSet
6263
.getAminoAcidCompoundSet()));
6364

64-
LinkedHashMap<String, ProteinSequence> proteinSequences = fastaReader
65+
Map<String, ProteinSequence> proteinSequences = fastaReader
6566
.process();
6667

6768
inStream.close();

‎biojava-core/src/main/java/demo/DemoSixFrameTranslation.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static void main(String[] args){
112112
new DNASequenceCreator(ambiguityDNACompoundSet));
113113

114114
// has only one entry in this example, but could be easily extended to parse a FASTA file with multiple sequences
115-
LinkedHashMap<String, DNASequence> dnaSequences = proxy.process();
115+
Map<String, DNASequence> dnaSequences = proxy.process();
116116

117117
// Initialize the Transcription Engine
118118
TranscriptionEngine engine = new

‎biojava-core/src/main/java/demo/ParseFastaFileDemo.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.io.File;
2525
import java.io.InputStream;
2626
import java.util.LinkedHashMap;
27+
import java.util.Map;
28+
2729
import org.biojava.nbio.core.sequence.ProteinSequence;
2830
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound;
2931
import org.biojava.nbio.core.sequence.compound.AminoAcidCompoundSet;
@@ -99,7 +101,7 @@ public static void main(String[] args) throws Exception {
99101
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
100102
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
101103

102-
LinkedHashMap<String, ProteinSequence> b;
104+
Map<String, ProteinSequence> b;
103105

104106
int nrSeq = 0;
105107

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.io.*;
3636
import java.util.HashMap;
3737
import java.util.LinkedHashMap;
38+
import java.util.Map;
3839

3940
/**
4041
* Use FastaReaderHelper as an example of how to use this class where FastaReaderHelper should be the
@@ -104,8 +105,8 @@ public FastaReader(File file, SequenceHeaderParserInterface<S,C> headerParser,
104105
* present, starting current fileIndex onwards.
105106
* @throws IOException if an error occurs reading the input file
106107
*/
107-
public LinkedHashMap<String,S> process() throws IOException {
108-
LinkedHashMap<String,S> sequences = process(-1);
108+
public Map<String, S> process() throws IOException {
109+
Map<String, S> sequences = process(-1);
109110
close();
110111

111112
return sequences;
@@ -131,7 +132,7 @@ public LinkedHashMap<String,S> process() throws IOException {
131132
* present, starting current fileIndex onwards.
132133
* @throws IOException if an error occurs reading the input file
133134
*/
134-
public LinkedHashMap<String,S> process(int max) throws IOException {
135+
public Map<String, S> process(int max) throws IOException {
135136

136137

137138
String line = "";
@@ -148,7 +149,7 @@ public LinkedHashMap<String,S> process(int max) throws IOException {
148149
boolean keepGoing = true;
149150

150151

151-
LinkedHashMap<String,S> sequences = new LinkedHashMap<>();
152+
Map<String, S> sequences = new LinkedHashMap<>();
152153

153154
do {
154155
line = line.trim(); // nice to have but probably not needed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.HashMap;
4949
import java.util.LinkedHashMap;
5050
import java.util.List;
51+
import java.util.Map;
5152

5253
/**
5354
* Use {@link GenbankReaderHelper} as an example of how to use this class where {@link GenbankReaderHelper} should be the
@@ -119,8 +120,8 @@ public GenbankReader(
119120
* @throws CompoundNotFoundException
120121
* @throws OutOfMemoryError if the input resource is larger than the allocated heap.
121122
*/
122-
public LinkedHashMap<String,S> process() throws IOException, CompoundNotFoundException {
123-
LinkedHashMap<String,S> result = process(-1);
123+
public Map<String, S> process() throws IOException, CompoundNotFoundException {
124+
Map<String, S> result = process(-1);
124125
close();
125126
return result;
126127
}
@@ -147,13 +148,13 @@ public LinkedHashMap<String,S> process() throws IOException, CompoundNotFoundExc
147148
* @throws IOException
148149
* @throws CompoundNotFoundException
149150
*/
150-
public LinkedHashMap<String,S> process(final int max) throws IOException, CompoundNotFoundException {
151+
public Map<String, S> process(final int max) throws IOException, CompoundNotFoundException {
151152

152153
if(closed){
153154
throw new IOException("Cannot perform action: resource has been closed.");
154155
}
155156

156-
LinkedHashMap<String,S> sequences = new LinkedHashMap<>();
157+
Map<String, S> sequences = new LinkedHashMap<>();
157158
int i=0;
158159
while(true) {
159160
if(max>0 && i>=max) break;

‎biojava-core/src/test/java/org/biojava/nbio/core/fasta/TestFASTAReader.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.InputStream;
2424
import java.util.LinkedHashMap;
25+
import java.util.Map;
2526

2627
import static org.junit.Assert.* ;
2728
import static org.hamcrest.CoreMatchers.* ;
@@ -46,7 +47,7 @@ private void testProcessAll(String path) throws Exception {
4647
inStream,
4748
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
4849
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
49-
LinkedHashMap<String, ProteinSequence> sequences = fastaReader.process();
50+
Map<String, ProteinSequence> sequences = fastaReader.process();
5051
assertThat(sequences,is(notNullValue()));
5152
assertThat(sequences.size(),is(1));
5253
assertThat(sequences.containsKey("P02768"),is(true));
@@ -86,12 +87,12 @@ private void testProcess1(String path) throws Exception {
8687
inStream,
8788
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
8889
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
89-
LinkedHashMap<String,ProteinSequence> out1 = fastaReader.process(1);
90+
Map<String,ProteinSequence> out1 = fastaReader.process(1);
9091
assertThat(out1,is(notNullValue()));
9192
assertThat(out1.size(),is(1));
9293
assertThat(out1.containsKey("P02768"),is(true));
9394
assertThat(out1.get("P02768").getLength(),is(609));
94-
LinkedHashMap<String,ProteinSequence> out2 = fastaReader.process(1);
95+
Map<String,ProteinSequence> out2 = fastaReader.process(1);
9596
assertThat(out2,is(nullValue()));
9697
} finally {
9798
if(fastaReader != null) fastaReader.close();
@@ -128,17 +129,17 @@ private void testProcess2(String path) throws Exception {
128129
inStream,
129130
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
130131
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
131-
LinkedHashMap<String,ProteinSequence> out1 = fastaReader.process(1);
132+
Map<String,ProteinSequence> out1 = fastaReader.process(1);
132133
assertThat(out1,is(notNullValue()));
133134
assertThat(out1.size(),is(1));
134135
assertThat(out1.containsKey("P02768"),is(true));
135136
assertThat(out1.get("P02768").getLength(),is(609));
136-
LinkedHashMap<String,ProteinSequence> out2 = fastaReader.process(1);
137+
Map<String,ProteinSequence> out2 = fastaReader.process(1);
137138
assertThat(out2,is(notNullValue()));
138139
assertThat(out2.size(),is(1));
139140
assertThat(out2.containsKey("P00698"),is(true));
140141
assertThat(out2.get("P00698").getLength(),is(147));
141-
LinkedHashMap<String,ProteinSequence> out3 = fastaReader.process(1);
142+
Map<String,ProteinSequence> out3 = fastaReader.process(1);
142143
assertThat(out3,is(nullValue()));
143144
} finally {
144145
if(fastaReader != null) fastaReader.close();

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.IOException;
3131
import java.io.InputStream;
3232
import java.util.LinkedHashMap;
33+
import java.util.Map;
3334
import java.util.logging.Level;
3435

3536
/**
@@ -70,7 +71,7 @@ public void testProcess() throws Exception {
7071

7172

7273
FastaReader<ProteinSequence,AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence,AminoAcidCompound>(inStream, new GenericFastaHeaderParser<ProteinSequence,AminoAcidCompound>(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
73-
LinkedHashMap<String,ProteinSequence> proteinSequences = fastaReader.process();
74+
Map<String,ProteinSequence> proteinSequences = fastaReader.process();
7475
inStream.close();
7576

7677
//Should have 282 sequences
@@ -107,7 +108,7 @@ public void processIntTest() throws Exception {
107108
InputStream inStream = this.getClass().getResourceAsStream("/PF00104_small.fasta");
108109
Assert.assertNotNull(inStream);
109110
FastaReader<ProteinSequence,AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence,AminoAcidCompound>(inStream, new GenericFastaHeaderParser<ProteinSequence,AminoAcidCompound>(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
110-
LinkedHashMap<String,ProteinSequence> proteinSequences = fastaReader.process(200);
111+
Map<String,ProteinSequence> proteinSequences = fastaReader.process(200);
111112

112113
//Should have 200 sequences
113114
//logger.debug("Expecting 200 got " + proteinSequences.size());
@@ -169,7 +170,7 @@ public void testSmallFasta() throws IOException {
169170
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
170171
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
171172

172-
LinkedHashMap<String, ProteinSequence> b;
173+
Map<String, ProteinSequence> b;
173174

174175
int nrSeq = 0;
175176

@@ -200,7 +201,7 @@ public void testSmallFasta2() throws IOException {
200201

201202
int nrSeq = 0;
202203

203-
LinkedHashMap<String, ProteinSequence> b = fastaReader.process();
204+
Map<String, ProteinSequence> b = fastaReader.process();
204205

205206
Assert.assertNotNull(b);
206207

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void testProcess() throws Exception {
6868
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())
6969
);
7070

71-
LinkedHashMap<String, ProteinSequence> proteinSequences = genbankProtein.process();
71+
Map<String, ProteinSequence> proteinSequences = genbankProtein.process();
7272

7373
assertThat(proteinSequences.get("NP_000257").getComments().get(0),is(
7474
"VALIDATED REFSEQ: This record has undergone validation or\n" +
@@ -114,7 +114,7 @@ public void testProcess() throws Exception {
114114
new GenericGenbankHeaderParser<>(),
115115
new DNASequenceCreator(DNACompoundSet.getDNACompoundSet())
116116
);
117-
LinkedHashMap<String, DNASequence> dnaSequences = genbankDNA.process();
117+
Map<String, DNASequence> dnaSequences = genbankDNA.process();
118118

119119
assertNotNull(dnaSequences);
120120
assertEquals(1, dnaSequences.size());
@@ -144,7 +144,7 @@ public void testPartialProcess() throws IOException, CompoundNotFoundException {
144144
);
145145

146146
// First call to process(1) returns the first sequence
147-
LinkedHashMap<String, DNASequence> dnaSequences = genbankDNA.process(1);
147+
Map<String, DNASequence> dnaSequences = genbankDNA.process(1);
148148

149149
assertFalse(inStream.isclosed());
150150
assertNotNull(dnaSequences);
@@ -177,7 +177,7 @@ public void CDStest() throws Exception {
177177
new GenericGenbankHeaderParser<>(),
178178
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())
179179
);
180-
LinkedHashMap<String, ProteinSequence> proteinSequences = GenbankProtein.process();
180+
Map<String, ProteinSequence> proteinSequences = GenbankProtein.process();
181181
assertTrue(inStream.isclosed());
182182

183183

@@ -206,7 +206,7 @@ private DNASequence readGenbankResource(final String resource) throws IOExceptio
206206
new GenericGenbankHeaderParser<>(),
207207
new DNASequenceCreator(DNACompoundSet.getDNACompoundSet())
208208
);
209-
LinkedHashMap<String, DNASequence> dnaSequences = genbankDNA.process();
209+
Map<String, DNASequence> dnaSequences = genbankDNA.process();
210210
return dnaSequences.values().iterator().next();
211211
}
212212

@@ -218,7 +218,7 @@ private RNASequence readGenbankRNAResource(final String resource) throws IOExcep
218218
new GenericGenbankHeaderParser<>(),
219219
new RNASequenceCreator(RNACompoundSet.getRNACompoundSet())
220220
);
221-
LinkedHashMap<String, RNASequence> rnaSequences = genbankRNA.process();
221+
Map<String, RNASequence> rnaSequences = genbankRNA.process();
222222
return rnaSequences.values().iterator().next();
223223
}
224224

@@ -230,7 +230,7 @@ private ProteinSequence readGenbankProteinResource(final String resource) throws
230230
new GenericGenbankHeaderParser<>(),
231231
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())
232232
);
233-
LinkedHashMap<String, ProteinSequence> proteinSequences = genbankProtein.process();
233+
Map<String, ProteinSequence> proteinSequences = genbankProtein.process();
234234
return proteinSequences.values().iterator().next();
235235
}
236236

@@ -346,7 +346,7 @@ public void testGithub843() throws Exception {
346346
new DNASequenceCreator(DNACompoundSet.getDNACompoundSet())
347347
);
348348

349-
LinkedHashMap<String, DNASequence> dnaSequences = genbankDNA.process();
349+
Map<String, DNASequence> dnaSequences = genbankDNA.process();
350350
assertNotNull(dnaSequences);
351351

352352
DNASequence dna = new ArrayList<>(dnaSequences.values()).get(0);

0 commit comments

Comments
 (0)