Skip to content

Commit 248cc08

Browse files
committed
Increased type checking.
1 parent 9cbd9ee commit 248cc08

File tree

7 files changed

+28
-27
lines changed

7 files changed

+28
-27
lines changed

biojava-core/src/main/java/org/biojava/nbio/core/search/io/Hsp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public boolean equals(Object obj) {
9393
public SequencePair<S,C> getAlignment(){
9494
if (returnAln != null) return returnAln;
9595

96-
SimpleAlignedSequence alignedQuery, alignedHit;
96+
SimpleAlignedSequence<S,C> alignedQuery, alignedHit;
9797
// queryFrom e hitTo?
9898
int numBefore, numAfter;
9999

@@ -125,7 +125,7 @@ else if (sequenceString.matches("^[ACUG]+$"))
125125
}
126126

127127
private List<Step> getAlignmentsSteps(String gappedSequenceString){
128-
List<Step> returnList = new ArrayList();
128+
List<Step> returnList = new ArrayList<Step>();
129129

130130
for (char c: gappedSequenceString.toCharArray()){
131131
if (c=='-') returnList.add(Step.GAP); else returnList.add(Step.COMPOUND);

biojava-core/src/main/java/org/biojava/nbio/core/search/io/ResultFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.text.ParseException;
66
import java.util.List;
7+
import org.biojava.nbio.core.sequence.template.Sequence;
78

89
/**
910
* Designed by Paolo Pavan.
@@ -45,11 +46,11 @@ public interface ResultFactory {
4546
* They will be associated back to the query during the construction of the Result object.
4647
* @param sequences
4748
*/
48-
void setQueryReferences(List sequences);
49+
void setQueryReferences(List<Sequence> sequences);
4950
/**
5051
* Specify the collection of sequences objects used as database in the Search run.
5152
* They will be associated back to the Hit during the construction of the Hit object.
5253
* @param sequences
5354
*/
54-
void setDatabaseReferences(List sequences);
55+
void setDatabaseReferences(List<Sequence> sequences);
5556
}

biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastTabularParser.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.biojava.nbio.core.search.io.Hsp;
1616
import org.biojava.nbio.core.search.io.Result;
1717
import org.biojava.nbio.core.search.io.ResultFactory;
18+
import org.biojava.nbio.core.sequence.template.Sequence;
1819

1920
/**
2021
* Designed by Paolo Pavan.
@@ -49,7 +50,7 @@ private enum PARSING_CONSISTENCY {
4950

5051
// data imported private:
5152
int queryIdNumber = 0;
52-
HashMap<String,String> queryIdMapping = new HashMap();
53+
HashMap<String,String> queryIdMapping = new HashMap<String,String>();
5354
String programName=null, queryName = null, databaseFile = null;
5455
private String queryId ;
5556
private String subjectId ;
@@ -67,7 +68,7 @@ private enum PARSING_CONSISTENCY {
6768

6869
@Override
6970
public List<String> getFileExtensions() {
70-
List l = new ArrayList();
71+
List<String> l = new ArrayList<String>();
7172
l.add("blasttabular");
7273
l.add("blasttxt");
7374
return l;
@@ -80,7 +81,7 @@ public void setFile(File f) {
8081

8182
@Override
8283
public List<Result> createObjects(double maxEScore) throws IOException, ParseException {
83-
List<Result> results = new ArrayList();
84+
List<Result> results = new ArrayList<Result>();
8485

8586
log.info("Query for hits");
8687
LineNumberReader lnr = new LineNumberReader(new FileReader(targetFile));
@@ -104,13 +105,13 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
104105
.setQueryDef(queryName)
105106
.setReference(blastReference);
106107

107-
List<Hit> hits = new ArrayList();
108+
List<Hit> hits = new ArrayList<Hit>();
108109

109110
String currentQueryId = queryId;
110111
while (currentQueryId.equals(queryId) && lineNumber < fileLinesCount){
111112
BlastHitBuilder hitBuilder = new BlastHitBuilder();
112113

113-
List<Hsp> hsps = new ArrayList();
114+
List<Hsp> hsps = new ArrayList<Hsp>();
114115

115116
String currentSubjectId=subjectId;
116117
while (currentSubjectId.equals(subjectId) && lineNumber < fileLinesCount){
@@ -206,7 +207,7 @@ public void storeObjects(List<Result> results) throws IOException, ParseExceptio
206207
* @param sequences
207208
*/
208209
@Override
209-
public void setQueryReferences(List sequences) {
210+
public void setQueryReferences(List<Sequence> sequences) {
210211
throw new UnsupportedOperationException("Not supported for this parser.");
211212
}
212213
/**
@@ -216,7 +217,7 @@ public void setQueryReferences(List sequences) {
216217
* @param sequences
217218
*/
218219
@Override
219-
public void setDatabaseReferences(List sequences) {
220+
public void setDatabaseReferences(List<Sequence> sequences) {
220221
throw new UnsupportedOperationException("Not supported for this parser.");
221222
}
222223
/**

biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastXMLParser.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
8383
ArrayList<Element> IterationsList = XMLHelper.selectElements(blastDoc.getDocumentElement(), "BlastOutput_iterations/Iteration[Iteration_hits]");
8484
logger.info(IterationsList.size() + " results");
8585

86-
resultsCollection = new ArrayList();
86+
resultsCollection = new ArrayList<Result>();
8787
for (Element element : IterationsList) {
8888
BlastResultBuilder resultBuilder = new BlastResultBuilder();
8989
// will add BlastOutput* key sections in the result object
@@ -109,7 +109,7 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
109109
Element iterationHitsElement = XMLHelper.selectSingleElement(element, "Iteration_hits");
110110
ArrayList<Element> hitList = XMLHelper.selectElements(iterationHitsElement, "Hit");
111111

112-
hitsCollection = new ArrayList();
112+
hitsCollection = new ArrayList<Hit>();
113113
for (Element hitElement : hitList) {
114114
BlastHitBuilder blastHitBuilder = new BlastHitBuilder();
115115
blastHitBuilder
@@ -126,7 +126,7 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
126126
Element hithspsElement = XMLHelper.selectSingleElement(hitElement, "Hit_hsps");
127127
ArrayList<Element> hspList = XMLHelper.selectElements(hithspsElement, "Hsp");
128128

129-
hspsCollection = new ArrayList();
129+
hspsCollection = new ArrayList<Hsp>();
130130
for (Element hspElement : hspList) {
131131
Double evalue = new Double(XMLHelper.selectSingleElement(hspElement, "Hsp_evalue").getTextContent());
132132

@@ -172,18 +172,18 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
172172
}
173173

174174
public List<String> getFileExtensions(){
175-
ArrayList<String> extensions = new ArrayList(1);
175+
ArrayList<String> extensions = new ArrayList<String>(1);
176176
extensions.add("blastxml");
177177
return extensions;
178178
}
179179

180180
@Override
181-
public void setQueryReferences(List sequences) {
181+
public void setQueryReferences(List<Sequence> sequences) {
182182
queryReferences = sequences;
183183
}
184184

185185
@Override
186-
public void setDatabaseReferences(List sequences) {
186+
public void setDatabaseReferences(List<Sequence> sequences) {
187187
databaseReferences = sequences;
188188
}
189189

@@ -192,15 +192,15 @@ public void setDatabaseReferences(List sequences) {
192192
*/
193193
private void mapIds() {
194194
if (queryReferences != null) {
195-
queryReferencesMap = new HashMap(queryReferences.size());
195+
queryReferencesMap = new HashMap<String,Sequence>(queryReferences.size());
196196
for (int counter=0; counter < queryReferences.size() ; counter ++){
197197
String id = "Query_"+(counter+1);
198198
queryReferencesMap.put(id, queryReferences.get(counter));
199199
}
200200
}
201201

202202
if (databaseReferences != null) {
203-
databaseReferencesMap = new HashMap(databaseReferences.size());
203+
databaseReferencesMap = new HashMap<String,Sequence>(databaseReferences.size());
204204
for (int counter=0; counter < databaseReferences.size() ; counter ++){
205205
// this is strange: while Query_id are 1 based, Hit (database) id are 0 based
206206
String id = "gnl|BL_ORD_ID|"+(counter);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
package org.biojava.nbio.core.alignment;
2525

26-
import org.biojava.nbio.core.alignment.SimpleAlignedSequence;
2726
import org.biojava.nbio.core.alignment.template.AlignedSequence;
2827
import org.biojava.nbio.core.alignment.template.AlignedSequence.Step;
2928
import org.biojava.nbio.core.exceptions.CompoundNotFoundException;

biojava-core/src/test/java/org/biojava/nbio/core/search/io/blast/BlastTabularParserTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testGetFileExtensions() {
4747
System.out.println("getFileExtensions");
4848
BlastTabularParser instance = new BlastTabularParser();
4949

50-
List<String> expResult = new ArrayList();
50+
List<String> expResult = new ArrayList<String>();
5151
expResult.add("blasttabular");
5252
expResult.add("blasttxt");
5353

@@ -113,15 +113,15 @@ public void testCreateObjects() throws Exception {
113113
.setHspBitScore(2894)
114114
.createBlastHsp();
115115

116-
List<Hsp> hsplist = new ArrayList();
116+
List<Hsp> hsplist = new ArrayList<Hsp>();
117117
hsplist.add(hsp1Hit1Res1);
118118
hsplist.add(hsp1Hit1Res2);
119119

120120
BlastHit hit1Res1 = new BlastHitBuilder()
121121
.setHitDef("CP000411")
122122
.setHsps(hsplist)
123123
.createBlastHit();
124-
List<Hit> hitlist = new ArrayList();
124+
List<Hit> hitlist = new ArrayList<Hit>();
125125
hitlist.add(hit1Res1);
126126

127127
BlastResult res1 = new BlastResultBuilder()

biojava-core/src/test/java/org/biojava/nbio/core/search/io/blast/BlastXMLParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void testCreateObjects() throws Exception {
9494
.setHspHseq("TTAAATTGAGAGTTTGATCCTGGCTCAGGATGAACGCTGGTGGCGTGCCTAATACATGCAAGTCGTACGCTAGCCGCTGAATTGATCCTTCGGGTGAAGTGAGGCAATGACTAGAGTGGCGAACTGGTGAGTAACACGTAAGAAACCTGCCCTTTAGTGGGGGATAACATTTGGAAACAGATGCTAATACCGCGTAACAACAAATCACACATGTGATCTGTTTGAAAGGTCCTTTTGGATCGCTAGAGGATGGTCTTGCGGCGTATTAGCTTGTTGGTAGGGTAGAAGCCTACCAAGGCAATGATGCGTAGCCGAGTTGAGAGACTGGCCGGCCACATTGGGACTGAGACACTGCCCAAACTCCTACGGGAGGCTGCAGTAGGGAATTTTCCGCAATGCACGAAAGTGTGACGGAGCGACGCCGCGTGTGTGATGAAGGCTTTCGGGTCGTAAAGCACTGTTGTAAGGGAAGAATAACTGAATTCAGAGAAAGTTTTCAGCTTGACGGTACCTTACCAGAAAGGGATGGCTAAATACGTGCCAGCAGCCGCGGTAATACGTATGTCCCGAGCGTTATCCGGATTTATTGGGCGTAAAGCGAGCGCAGACGGTTTATTAAGTCTGATGTGAAATCCCGAGGCCCAACCTCGGAACTGCATTGGAAACTGATTTACTTGAGTGCGATAGAGGCAAGTGGAACTCCATGTGTAGCGGTGAAATGCGTAGATATGTGGAAGAACACCAGTGGCGAAAGCGGCTTGCTAGATCGTAACTGACGTTGAGGCTCGAAAGTATGGGTAGCAAACGGGATTAGATACCCCGGTAGTCCATACCGTAAACGATGGGTGCTAGTTGTTAAGAGGTTTCCGCCTCCTAGTGACGTAGCAAACGCATTAAGCACCCCGCCTGAGGAGTACGGCCGCAAGGCTAAAACTTAAAGGAATTGACGGGGACCCGCACAAGCGGTGGAGCATGTGGTTTAATTCGAAGATACGCGAAAAACCTTACCAGGTCTTGACATACCAATGATCGCTTTTGTAATGAAAGCTTTTCTTCGGAACATTGGATACAGGTGGTGCATGGTCGTCGTCAGCTCGTGTCGTGAGATGTTGGGTTAAGTCCCGCAACGAGCGCAACCCTTGTTATTAGTTGCCAGCATTTAGTTGGGCACTCTAATGAGACTGCCGGTGATAAACCGGAGGAAGGTGGGGACGACGTCAGATCATCATGCCCCTTATGACCTGGGCAACACACGTGCTACAATGGGAAGTACAACGAGTCGCAAACCGGCGACGGTAAGCTAATCTCTTAAAACTTCTCTCAGTTCGGACTGGAGTCTGCAACTCGACTCCACGAAGGCGGAATCGCTAGTAATCGCGAATCAGCATGTCGCGGTGAATACGTTCCCGGGTCTTGTACACACCGCCCGTCAAATCATGGGAGTCGGAAGTACCCAAAGTCGCTTGGCTAACTTTTAGAGGCCGGTGCCTAAGGTAAAATCGATGACTGGGATTAAGTCGTAACAAGGTAGCCGTAGGAGAACCTGCGGCTGGATCACCTCCTTTCT")
9595
.setHspIdentityString("|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
9696
.createBlastHsp();
97-
List<Hsp> hsplist = new ArrayList();
97+
List<Hsp> hsplist = new ArrayList<Hsp>();
9898
hsplist.add(hsp1hit1res1);
9999
hsplist.add(hsp1hit1res1);
100100

@@ -107,7 +107,7 @@ public void testCreateObjects() throws Exception {
107107
.setHsps(hsplist)
108108
.createBlastHit();
109109

110-
List<Hit> hitlist = new ArrayList();
110+
List<Hit> hitlist = new ArrayList<Hit>();
111111
hitlist.add(hit1res1);
112112

113113
BlastResult res1 = new BlastResultBuilder()
@@ -150,7 +150,7 @@ public void testGetFileExtensions() {
150150
@Test
151151
@Ignore public void testSetQueryReferences() {
152152
System.out.println("setQueryReferences");
153-
List sequences = null;
153+
List<org.biojava.nbio.core.sequence.template.Sequence> sequences = null;
154154
BlastXMLParser instance = new BlastXMLParser();
155155
instance.setQueryReferences(sequences);
156156
// TODO review the generated test code and remove the default call to fail.
@@ -163,7 +163,7 @@ public void testGetFileExtensions() {
163163
@Test
164164
@Ignore public void testSetDatabaseReferences() {
165165
System.out.println("setDatabaseReferences");
166-
List sequences = null;
166+
List<org.biojava.nbio.core.sequence.template.Sequence> sequences = null;
167167
BlastXMLParser instance = new BlastXMLParser();
168168
instance.setDatabaseReferences(sequences);
169169
// TODO review the generated test code and remove the default call to fail.

0 commit comments

Comments
 (0)