diff --git a/biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/CommandPrompt.java b/biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/CommandPrompt.java index 727c83b388..514ccfbc54 100644 --- a/biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/CommandPrompt.java +++ b/biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/CommandPrompt.java @@ -82,7 +82,7 @@ private static void readInputAndGenerateOutput(String outputLocation, List a = readInputFile(inputLocation, aaTable); + Map a = readInputFile(inputLocation, aaTable); //Need for the last sequence for(Entry entry:a.entrySet()){ compute(output, entry.getValue().getOriginalHeader(), entry.getValue().getSequenceAsString().trim(), delimiter, aaTable, propertyList, specificList, @@ -169,7 +169,7 @@ public static void run(String[] args) throws Exception{ readInputAndGenerateOutput(outputLocation, propertyList, specificList, delimiter, inputLocation, aaTable, decimalPlace); } - private static LinkedHashMap readInputFile(String inputLocation, AminoAcidCompositionTable aaTable) throws Exception{ + private static Map readInputFile(String inputLocation, AminoAcidCompositionTable aaTable) throws Exception{ FileInputStream inStream = new FileInputStream(inputLocation); CompoundSet set; if(aaTable == null){ @@ -177,7 +177,7 @@ private static LinkedHashMap readInputFile(String input }else{ set = aaTable.getAminoAcidCompoundSet(); } - LinkedHashMap ret; + Map ret; if ( inputLocation.toLowerCase().contains(".gb")) { GenbankReader genbankReader = new GenbankReader<>( inStream, new GenericGenbankHeaderParser(), diff --git a/biojava-alignment/src/main/java/demo/DemoDistanceTree.java b/biojava-alignment/src/main/java/demo/DemoDistanceTree.java index e7e0561a9d..9215fa43dc 100644 --- a/biojava-alignment/src/main/java/demo/DemoDistanceTree.java +++ b/biojava-alignment/src/main/java/demo/DemoDistanceTree.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.util.LinkedHashMap; +import java.util.Map; import org.biojava.nbio.core.alignment.matrices.SubstitutionMatrixHelper; import org.biojava.nbio.core.alignment.template.SubstitutionMatrix; @@ -64,7 +65,7 @@ public static void main(String[] args) throws Exception { new ProteinSequenceCreator(AminoAcidCompoundSet .getAminoAcidCompoundSet())); - LinkedHashMap proteinSequences = + Map proteinSequences = fastaReader.process(); inStream.close(); diff --git a/biojava-alignment/src/test/java/org/biojava/nbio/alignment/TestDNAAlignment.java b/biojava-alignment/src/test/java/org/biojava/nbio/alignment/TestDNAAlignment.java index 169babaf04..aeb839747f 100644 --- a/biojava-alignment/src/test/java/org/biojava/nbio/alignment/TestDNAAlignment.java +++ b/biojava-alignment/src/test/java/org/biojava/nbio/alignment/TestDNAAlignment.java @@ -43,6 +43,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; public class TestDNAAlignment { @@ -75,7 +76,7 @@ public void testDNAAlignment() { private static List getDNAFASTAFile() throws Exception { InputStream inStream = TestDNAAlignment.class.getResourceAsStream(String.format("/dna-fasta.txt")); - LinkedHashMap fastas = FastaReaderHelper.readFastaDNASequence(inStream); + Map fastas = FastaReaderHelper.readFastaDNASequence(inStream); List sequences = new ArrayList(); diff --git a/biojava-alignment/src/test/java/org/biojava/nbio/phylo/TestForesterWrapper.java b/biojava-alignment/src/test/java/org/biojava/nbio/phylo/TestForesterWrapper.java index c4fe468852..6f7d749a0a 100644 --- a/biojava-alignment/src/test/java/org/biojava/nbio/phylo/TestForesterWrapper.java +++ b/biojava-alignment/src/test/java/org/biojava/nbio/phylo/TestForesterWrapper.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.LinkedHashMap; +import java.util.Map; import org.biojava.nbio.core.sequence.MultipleSequenceAlignment; import org.biojava.nbio.core.sequence.ProteinSequence; @@ -61,7 +62,7 @@ public void testMSAconversion() throws Exception { new ProteinSequenceCreator(AminoAcidCompoundSet .getAminoAcidCompoundSet())); - LinkedHashMap proteinSequences = fastaReader + Map proteinSequences = fastaReader .process(); inStream.close(); diff --git a/biojava-core/src/main/java/demo/DemoSixFrameTranslation.java b/biojava-core/src/main/java/demo/DemoSixFrameTranslation.java index cf321baee6..57b1560841 100644 --- a/biojava-core/src/main/java/demo/DemoSixFrameTranslation.java +++ b/biojava-core/src/main/java/demo/DemoSixFrameTranslation.java @@ -112,7 +112,7 @@ public static void main(String[] args){ new DNASequenceCreator(ambiguityDNACompoundSet)); // has only one entry in this example, but could be easily extended to parse a FASTA file with multiple sequences - LinkedHashMap dnaSequences = proxy.process(); + Map dnaSequences = proxy.process(); // Initialize the Transcription Engine TranscriptionEngine engine = new diff --git a/biojava-core/src/main/java/demo/ParseFastaFileDemo.java b/biojava-core/src/main/java/demo/ParseFastaFileDemo.java index 7361de9974..9ad1bacbb4 100644 --- a/biojava-core/src/main/java/demo/ParseFastaFileDemo.java +++ b/biojava-core/src/main/java/demo/ParseFastaFileDemo.java @@ -24,6 +24,8 @@ import java.io.File; import java.io.InputStream; import java.util.LinkedHashMap; +import java.util.Map; + import org.biojava.nbio.core.sequence.ProteinSequence; import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; import org.biojava.nbio.core.sequence.compound.AminoAcidCompoundSet; @@ -99,7 +101,7 @@ public static void main(String[] args) throws Exception { new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); - LinkedHashMap b; + Map b; int nrSeq = 0; diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/Result.java b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/Result.java index aa1b432b57..bebdfea5ff 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/Result.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/Result.java @@ -27,6 +27,7 @@ import java.util.NoSuchElementException; import org.biojava.nbio.core.sequence.template.Sequence; +import java.util.Map; /** * This class models a search result. @@ -46,7 +47,7 @@ public abstract class Result implements Iterable{ private String reference; private String dbFile; - private HashMap programSpecificParameters; + private Map programSpecificParameters; private int iterationNumber; private String queryID; @@ -56,7 +57,7 @@ public abstract class Result implements Iterable{ private List hits; private int hitCounter = -1; - public Result(String program, String version, String reference, String dbFile, HashMap programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List hits, Sequence querySequence) { + public Result(String program, String version, String reference, String dbFile, Map programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List hits, Sequence querySequence) { this.program = program; this.version = version; this.reference = reference; diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/SearchIO.java b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/SearchIO.java index d10717ee9e..95ffb9fcfc 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/SearchIO.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/SearchIO.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.ServiceLoader; import java.util.NoSuchElementException; +import java.util.Map; /** * Designed by Paolo Pavan. @@ -39,7 +40,7 @@ */ public class SearchIO implements Iterable{ - static private HashMap extensionFactoryAssociation; + static private Map extensionFactoryAssociation; final private ResultFactory factory; final private File file; diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResult.java b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResult.java index bcacdde20d..9410becea0 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResult.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResult.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.List; import org.biojava.nbio.core.sequence.template.Sequence; +import java.util.Map; /** * This class models a Blast/Blast plus result. @@ -39,7 +40,7 @@ * */ public class BlastResult extends Result{ - public BlastResult(String program, String version, String reference, String dbFile, HashMap programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List hits, Sequence querySequence) { + public BlastResult(String program, String version, String reference, String dbFile, Map programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List hits, Sequence querySequence) { super(program, version, reference, dbFile, programSpecificParameters, iterationNumber, queryID, queryDef, queryLength, hits, querySequence); } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResultBuilder.java b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResultBuilder.java index 8d7e06a89e..5c26f4b63a 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResultBuilder.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastResultBuilder.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import org.biojava.nbio.core.sequence.template.Sequence; +import java.util.Map; /** * Designed by Paolo Pavan. @@ -39,7 +40,7 @@ public class BlastResultBuilder { private String version; private String reference; private String dbFile; - private HashMap programSpecificParameters; + private Map programSpecificParameters; private int iterationNumber; private String queryID; private String queryDef; @@ -70,7 +71,7 @@ public BlastResultBuilder setDbFile(String dbFile) { return this; } - public BlastResultBuilder setProgramSpecificParameters(HashMap programSpecificParameters) { + public BlastResultBuilder setProgramSpecificParameters(Map programSpecificParameters) { this.programSpecificParameters = programSpecificParameters; return this; } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastTabularParser.java b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastTabularParser.java index be3d2f81f1..03c4b6ba64 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastTabularParser.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastTabularParser.java @@ -37,6 +37,7 @@ import org.biojava.nbio.core.sequence.template.Sequence; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; /** * Designed by Paolo Pavan. @@ -71,7 +72,7 @@ private enum PARSING_CONSISTENCY { // data imported private: int queryIdNumber = 0; - HashMap queryIdMapping = new HashMap<>(); + Map queryIdMapping = new HashMap<>(); String programName=null, queryName = null, databaseFile = null; private String queryId ; private String subjectId ; diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastXMLParser.java b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastXMLParser.java index 7714f44749..73932d9147 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastXMLParser.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastXMLParser.java @@ -90,9 +90,9 @@ public List createObjects(double maxEScore) throws IOException, ParseExc // create mappings between sequences and blast id mapIds(); - ArrayList resultsCollection; - ArrayList hitsCollection; - ArrayList hspsCollection; + List resultsCollection; + List hitsCollection; + List hspsCollection; try { // select top level elements @@ -102,7 +102,7 @@ public List createObjects(double maxEScore) throws IOException, ParseExc String dbFile = XMLHelper.selectSingleElement(blastDoc.getDocumentElement(),"BlastOutput_db").getTextContent(); logger.info("Query for hits in "+ targetFile); - ArrayList IterationsList = XMLHelper.selectElements(blastDoc.getDocumentElement(), "BlastOutput_iterations/Iteration[Iteration_hits]"); + List IterationsList = XMLHelper.selectElements(blastDoc.getDocumentElement(), "BlastOutput_iterations/Iteration[Iteration_hits]"); logger.info(IterationsList.size() + " results"); resultsCollection = new ArrayList<>(); @@ -129,7 +129,7 @@ public List createObjects(double maxEScore) throws IOException, ParseExc Element iterationHitsElement = XMLHelper.selectSingleElement(element, "Iteration_hits"); - ArrayList hitList = XMLHelper.selectElements(iterationHitsElement, "Hit"); + List hitList = XMLHelper.selectElements(iterationHitsElement, "Hit"); hitsCollection = new ArrayList<>(); for (Element hitElement : hitList) { @@ -146,7 +146,7 @@ public List createObjects(double maxEScore) throws IOException, ParseExc )); Element hithspsElement = XMLHelper.selectSingleElement(hitElement, "Hit_hsps"); - ArrayList hspList = XMLHelper.selectElements(hithspsElement, "Hsp"); + List hspList = XMLHelper.selectElements(hithspsElement, "Hsp"); hspsCollection = new ArrayList<>(); for (Element hspElement : hspList) { @@ -195,7 +195,7 @@ public List createObjects(double maxEScore) throws IOException, ParseExc @Override public List getFileExtensions(){ - ArrayList extensions = new ArrayList<>(1); + List extensions = new ArrayList<>(1); extensions.add("blastxml"); return extensions; } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ChromosomeSequence.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ChromosomeSequence.java index 8b11fa0b63..4a7e1ec575 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ChromosomeSequence.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ChromosomeSequence.java @@ -29,6 +29,7 @@ import org.biojava.nbio.core.sequence.template.SequenceReader; import java.util.LinkedHashMap; +import java.util.Map; /** * A ChromosomeSequence is a DNASequence but keeps track of geneSequences @@ -37,7 +38,7 @@ public class ChromosomeSequence extends DNASequence { private int chromosomeNumber; - private LinkedHashMap geneSequenceHashMap = new LinkedHashMap<>(); + private Map geneSequenceHashMap = new LinkedHashMap<>(); /** * Empty constructor used by tools that need a proper Bean that allows the actual @@ -106,7 +107,7 @@ public void setChromosomeNumber(int chromosomeNumber) { * @return */ - public LinkedHashMap getGeneSequences() { + public Map getGeneSequences() { return geneSequenceHashMap; } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/GeneSequence.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/GeneSequence.java index ed6f635611..f0f2662fea 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/GeneSequence.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/GeneSequence.java @@ -32,6 +32,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.Map; +import java.util.List; /** * @@ -41,11 +43,11 @@ public class GeneSequence extends DNASequence { private final static Logger logger = LoggerFactory.getLogger(GeneSequence.class); - private final LinkedHashMap transcriptSequenceHashMap = new LinkedHashMap<>(); - private final LinkedHashMap intronSequenceHashMap = new LinkedHashMap<>(); - private final LinkedHashMap exonSequenceHashMap = new LinkedHashMap<>(); - private final ArrayList intronSequenceList = new ArrayList<>(); - private final ArrayList exonSequenceList = new ArrayList<>(); + private final Map transcriptSequenceHashMap = new LinkedHashMap<>(); + private final Map intronSequenceHashMap = new LinkedHashMap<>(); + private final Map exonSequenceHashMap = new LinkedHashMap<>(); + private final List intronSequenceList = new ArrayList<>(); + private final List exonSequenceList = new ArrayList<>(); boolean intronAdded = false; // need to deal with the problem that typically introns are not added when validating the list and adding in introns as the regions not included in exons private Strand strand = Strand.UNDEFINED; private ChromosomeSequence chromosomeSequence; @@ -179,7 +181,7 @@ public TranscriptSequence getTranscript(String accession) { * Get the collection of transcription sequences assigned to this gene * @return transcripts */ - public LinkedHashMap getTranscripts() { + public Map getTranscripts() { return transcriptSequenceHashMap; } @@ -294,7 +296,7 @@ public ExonSequence addExon(AccessionID accession, int begin, int end) { * Get the exons as an ArrayList. Modifying this list will not modify the underlying collection * @return exons */ - public ArrayList getExonSequences() { + public List getExonSequences() { return new ArrayList<>(exonSequenceList); } @@ -302,7 +304,7 @@ public ArrayList getExonSequences() { * Get the introns as an ArrayList. Modifying this list will not modify the underlying collection * @return introns */ - public ArrayList getIntronSequences() { + public List getIntronSequences() { return new ArrayList<>(intronSequenceList); } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ProteinSequence.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ProteinSequence.java index 4248bc908c..f4194bc662 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ProteinSequence.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ProteinSequence.java @@ -42,6 +42,7 @@ import java.util.LinkedHashMap; import java.util.List; import org.biojava.nbio.core.sequence.features.Qualifier; +import java.util.Map; /** * The representation of a ProteinSequence @@ -163,7 +164,7 @@ private DNASequence getRawParentSequence(String accessId) throws IOException { = new FastaReader<>(is, new PlainFastaHeaderParser(), new DNASequenceCreator(AmbiguityDNACompoundSet.getDNACompoundSet())); - LinkedHashMap seq = parentReader.process(); + Map seq = parentReader.process(); DNASequence parentSeq = null; if (seq.size() == 1) { diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/TranscriptSequence.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/TranscriptSequence.java index 460ca6ab45..5fa81ecf7f 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/TranscriptSequence.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/TranscriptSequence.java @@ -31,6 +31,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * This is the sequence if you want to go from a gene sequence to a protein sequence. Need to start with a @@ -41,8 +43,8 @@ public class TranscriptSequence extends DNASequence { private final static Logger logger = LoggerFactory.getLogger(TranscriptSequence.class); - private final ArrayList cdsSequenceList = new ArrayList<>(); - private final LinkedHashMap cdsSequenceHashMap = new LinkedHashMap<>(); + private final List cdsSequenceList = new ArrayList<>(); + private final Map cdsSequenceHashMap = new LinkedHashMap<>(); private StartCodonSequence startCodonSequence = null; private StopCodonSequence stopCodonSequence = null; private GeneSequence parentGeneSequence = null; @@ -110,7 +112,7 @@ public CDSSequence removeCDS(String accession) { * Get the CDS sequences that have been added to the TranscriptSequences * @return */ - public LinkedHashMap getCDSSequences() { + public Map getCDSSequences() { return cdsSequenceHashMap; } @@ -152,8 +154,8 @@ public CDSSequence addCDS(AccessionID accession, int begin, int end, int phase) * * @return */ - public ArrayList getProteinCDSSequences() { - ArrayList proteinSequenceList = new ArrayList<>(); + public List getProteinCDSSequences() { + List proteinSequenceList = new ArrayList<>(); for (int i = 0; i < cdsSequenceList.size(); i++) { CDSSequence cdsSequence = cdsSequenceList.get(i); String codingSequence = cdsSequence.getCodingSequence(); diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/features/DBReferenceInfo.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/features/DBReferenceInfo.java index 0d2ff2de9a..7598f77f33 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/features/DBReferenceInfo.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/features/DBReferenceInfo.java @@ -25,6 +25,7 @@ import org.biojava.nbio.core.sequence.loader.UniprotProxySequenceReader; import java.util.LinkedHashMap; +import java.util.Map; /** * If you have a uniprot ID then it is possible to get a collection @@ -37,7 +38,7 @@ * @author Paolo Pavan */ public class DBReferenceInfo extends Qualifier { - private LinkedHashMap properties = new LinkedHashMap<>(); + private Map properties = new LinkedHashMap<>(); private String database = ""; private String id = ""; @@ -66,14 +67,14 @@ public void addProperty(String type, String value){ * Get the properties * @return the properties */ - public LinkedHashMap getProperties() { + public Map getProperties() { return properties; } /** * @param properties the properties to set */ - public void setProperties(LinkedHashMap properties) { + public void setProperties(Map properties) { this.properties = properties; } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReader.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReader.java index bdcc197f7e..f818adddd0 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReader.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReader.java @@ -35,6 +35,7 @@ import java.io.*; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.Map; /** * 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 headerParser, * present, starting current fileIndex onwards. * @throws IOException if an error occurs reading the input file */ - public LinkedHashMap process() throws IOException { - LinkedHashMap sequences = process(-1); + public Map process() throws IOException { + Map sequences = process(-1); close(); return sequences; @@ -131,7 +132,7 @@ public LinkedHashMap process() throws IOException { * present, starting current fileIndex onwards. * @throws IOException if an error occurs reading the input file */ - public LinkedHashMap process(int max) throws IOException { + public Map process(int max) throws IOException { String line = ""; @@ -148,7 +149,7 @@ public LinkedHashMap process(int max) throws IOException { boolean keepGoing = true; - LinkedHashMap sequences = new LinkedHashMap<>(); + Map sequences = new LinkedHashMap<>(); do { line = line.trim(); // nice to have but probably not needed diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReaderHelper.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReaderHelper.java index d185a6f062..4493766202 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReaderHelper.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaReaderHelper.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.LinkedHashMap; +import java.util.Map; /** * @@ -51,7 +52,7 @@ public class FastaReaderHelper { * @return * @throws IOException */ - public static LinkedHashMap readFastaDNASequence(File file, boolean lazySequenceLoad) throws IOException { + public static Map readFastaDNASequence(File file, boolean lazySequenceLoad) throws IOException { if (!lazySequenceLoad) { return readFastaDNASequence(file); } @@ -79,7 +80,7 @@ public static LinkedHashMap readFastaDNASequence(File file, * @return * @throws IOException */ - public static LinkedHashMap readFastaRNASequence(File file, boolean lazySequenceLoad) throws IOException { + public static Map readFastaRNASequence(File file, boolean lazySequenceLoad) throws IOException { if (!lazySequenceLoad) { return readFastaRNASequence(file); } @@ -106,10 +107,10 @@ public static LinkedHashMap readFastaRNASequence(File file, * @return * @throws IOException */ - public static LinkedHashMap readFastaProteinSequence( + public static Map readFastaProteinSequence( File file) throws IOException { FileInputStream inStream = new FileInputStream(file); - LinkedHashMap proteinSequences = readFastaProteinSequence(inStream); + Map proteinSequences = readFastaProteinSequence(inStream); inStream.close(); return proteinSequences; } @@ -122,7 +123,7 @@ public static LinkedHashMap readFastaProteinSequence( * @return * @throws IOException */ - public static LinkedHashMap readFastaProteinSequence( + public static Map readFastaProteinSequence( InputStream inStream) throws IOException { FastaReader fastaReader = new FastaReader<>( inStream, @@ -137,7 +138,7 @@ public static LinkedHashMap readFastaProteinSequence( * @return * @throws IOException */ - public static LinkedHashMap readFastaDNASequence( + public static Map readFastaDNASequence( InputStream inStream) throws IOException { FastaReader fastaReader = new FastaReader<>( inStream, @@ -152,10 +153,10 @@ public static LinkedHashMap readFastaDNASequence( * @return * @throws IOException */ - public static LinkedHashMap readFastaDNASequence( + public static Map readFastaDNASequence( File file) throws IOException { FileInputStream inStream = new FileInputStream(file); - LinkedHashMap dnaSequences = readFastaDNASequence(inStream); + Map dnaSequences = readFastaDNASequence(inStream); inStream.close(); return dnaSequences; } @@ -166,7 +167,7 @@ public static LinkedHashMap readFastaDNASequence( * @return * @throws IOException */ - public static LinkedHashMap readFastaRNASequence( + public static Map readFastaRNASequence( InputStream inStream) throws IOException { FastaReader fastaReader = new FastaReader<>( inStream, @@ -181,10 +182,10 @@ public static LinkedHashMap readFastaRNASequence( * @return * @throws IOException */ - public static LinkedHashMap readFastaRNASequence( + public static Map readFastaRNASequence( File file) throws IOException { FileInputStream inStream = new FileInputStream(file); - LinkedHashMap rnaSequences = readFastaRNASequence(inStream); + Map rnaSequences = readFastaRNASequence(inStream); inStream.close(); return rnaSequences; } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaStreamer.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaStreamer.java index c9184dfd13..00829869b9 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaStreamer.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaStreamer.java @@ -36,7 +36,7 @@ public class FastaStreamer { private int batchSize = 1_000; private SequenceHeaderParserInterface headerParser; private SequenceCreatorInterface sequenceCreator; - private LinkedHashMap chunk = new LinkedHashMap<>(); + private Map chunk = new LinkedHashMap<>(); private Iterator> iterator = Collections.emptyIterator(); private boolean closed = false; diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReader.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReader.java index 1b182f02dc..e2f4e8bf25 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReader.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReader.java @@ -48,6 +48,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; /** * Use {@link GenbankReaderHelper} as an example of how to use this class where {@link GenbankReaderHelper} should be the @@ -119,8 +120,8 @@ public GenbankReader( * @throws CompoundNotFoundException * @throws OutOfMemoryError if the input resource is larger than the allocated heap. */ - public LinkedHashMap process() throws IOException, CompoundNotFoundException { - LinkedHashMap result = process(-1); + public Map process() throws IOException, CompoundNotFoundException { + Map result = process(-1); close(); return result; } @@ -147,13 +148,13 @@ public LinkedHashMap process() throws IOException, CompoundNotFoundExc * @throws IOException * @throws CompoundNotFoundException */ - public LinkedHashMap process(final int max) throws IOException, CompoundNotFoundException { + public Map process(final int max) throws IOException, CompoundNotFoundException { if(closed){ throw new IOException("Cannot perform action: resource has been closed."); } - LinkedHashMap sequences = new LinkedHashMap<>(); + Map sequences = new LinkedHashMap<>(); int i=0; while(true) { if(max>0 && i>=max) break; diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReaderHelper.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReaderHelper.java index 2a1d30f146..5146310591 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReaderHelper.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankReaderHelper.java @@ -37,6 +37,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.util.LinkedHashMap; +import java.util.Map; /** * @@ -55,7 +56,7 @@ public class GenbankReaderHelper { * @return * @throws Exception */ - public static LinkedHashMap readGenbankDNASequence(File file, boolean lazySequenceLoad) throws Exception { + public static Map readGenbankDNASequence(File file, boolean lazySequenceLoad) throws Exception { if (!lazySequenceLoad) { return readGenbankDNASequence(file); } @@ -83,7 +84,7 @@ public static LinkedHashMap readGenbankDNASequence(File fil * @return * @throws Exception */ - public static LinkedHashMap readGenbankProteinSequence(File file, boolean lazySequenceLoad) throws Exception { + public static Map readGenbankProteinSequence(File file, boolean lazySequenceLoad) throws Exception { if (!lazySequenceLoad) { return readGenbankProteinSequence(file); } @@ -111,7 +112,7 @@ public static LinkedHashMap readGenbankProteinSequence( * @return * @throws Exception */ - public static LinkedHashMap readGenbankRNASequence(File file, boolean lazySequenceLoad) throws Exception { + public static Map readGenbankRNASequence(File file, boolean lazySequenceLoad) throws Exception { if (!lazySequenceLoad) { return readGenbankRNASequence(file); } @@ -138,10 +139,10 @@ public static LinkedHashMap readGenbankRNASequence(File fil * @return * @throws Exception */ - public static LinkedHashMap readGenbankProteinSequence( + public static Map readGenbankProteinSequence( File file) throws Exception { FileInputStream inStream = new FileInputStream(file); - LinkedHashMap proteinSequences = readGenbankProteinSequence(inStream); + Map proteinSequences = readGenbankProteinSequence(inStream); inStream.close(); return proteinSequences; } @@ -154,7 +155,7 @@ public static LinkedHashMap readGenbankProteinSequence( * @return * @throws Exception */ - public static LinkedHashMap readGenbankProteinSequence( + public static Map readGenbankProteinSequence( InputStream inStream) throws Exception { GenbankReader GenbankReader = new GenbankReader<>( inStream, @@ -169,7 +170,7 @@ public static LinkedHashMap readGenbankProteinSequence( * @return * @throws Exception */ - public static LinkedHashMap readGenbankDNASequence( + public static Map readGenbankDNASequence( InputStream inStream) throws Exception { GenbankReader GenbankReader = new GenbankReader<>( inStream, @@ -184,10 +185,10 @@ public static LinkedHashMap readGenbankDNASequence( * @return * @throws Exception */ - public static LinkedHashMap readGenbankDNASequence( + public static Map readGenbankDNASequence( File file) throws Exception { FileInputStream inStream = new FileInputStream(file); - LinkedHashMap dnaSequences = readGenbankDNASequence(inStream); + Map dnaSequences = readGenbankDNASequence(inStream); inStream.close(); return dnaSequences; } @@ -197,7 +198,7 @@ public static LinkedHashMap readGenbankDNASequence( * @return * @throws Exception */ - public static LinkedHashMap readGenbankRNASequence( + public static Map readGenbankRNASequence( InputStream inStream) throws Exception { GenbankReader GenbankReader = new GenbankReader<>( inStream, @@ -212,10 +213,10 @@ public static LinkedHashMap readGenbankRNASequence( * @return * @throws Exception */ - public static LinkedHashMap readGenbankRNASequence( + public static Map readGenbankRNASequence( File file) throws Exception { FileInputStream inStream = new FileInputStream(file); - LinkedHashMap rnaSequences = readGenbankRNASequence(inStream); + Map rnaSequences = readGenbankRNASequence(inStream); inStream.close(); return rnaSequences; } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java index 62847e7456..90653612e7 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java @@ -217,7 +217,7 @@ private void parseFeatureTag(List section) { xref.setNeedsQuotes(needsQuotes); gbFeature.addQualifier(key, xref); - ArrayList listDBEntry = new ArrayList<>(); + List listDBEntry = new ArrayList<>(); listDBEntry.add(xref); mapDB.put(key, listDBEntry); } else { diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericFastaHeaderParser.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericFastaHeaderParser.java index ee5c3142eb..1556bf838e 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericFastaHeaderParser.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericFastaHeaderParser.java @@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.List; /** * The default fasta header parser where some headers are well defined based on the source @@ -71,7 +72,7 @@ public class GenericFastaHeaderParser, C extends C */ private String[] getHeaderValues(String header) { String[] data = new String[0]; - ArrayList values = new ArrayList<>(); + List values = new ArrayList<>(); StringBuffer sb = new StringBuffer(); //commented out 1/11/2012 to resolve an issue where headers do contain a length= at the end that are not recognized //if(header.indexOf("length=") != -1){ diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderFormat.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderFormat.java index 18f58ee7c5..036f8d2ab5 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderFormat.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderFormat.java @@ -76,7 +76,7 @@ private String _write_multi_line(String tag, String text) { text = ""; } int max_len = MAX_WIDTH - HEADER_WIDTH; - ArrayList lines = _split_multi_line(text, max_len); + List lines = _split_multi_line(text, max_len); String output = _write_single_line(tag, lines.get(0)); for (int i = 1; i < lines.size(); i++) { output += _write_single_line("", lines.get(i)); @@ -254,7 +254,7 @@ private String _write_original_first_line(S sequence) { * @param sequence */ private String _write_comment(S sequence) { - ArrayList comments = sequence.getNotesList(); + List comments = sequence.getNotesList(); String output = _write_multi_line("COMMENT", comments.remove(0)); for (String comment : comments) { output += _write_multi_line("", comment); diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderParser.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderParser.java index bc196c9150..7b1dc0524d 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderParser.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericGenbankHeaderParser.java @@ -67,7 +67,7 @@ public class GenericGenbankHeaderParser, C extends private boolean versionSeen; - private ArrayList comments = new ArrayList<>(); + private List comments = new ArrayList<>(); /** * Publications by the authors of the sequence that discuss the data reported in @@ -134,7 +134,7 @@ public int getVersion() { return version; } - public ArrayList getComments() { + public List getComments() { return comments; } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericInsdcHeaderFormat.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericInsdcHeaderFormat.java index 71e5f9379d..ccc7dc2055 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericInsdcHeaderFormat.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenericInsdcHeaderFormat.java @@ -208,7 +208,7 @@ private String _insdc_feature_location_string(FeatureInterface locations = new ArrayList<>(); + List locations = new ArrayList<>(); for(Location l : feature.getLocations().getSubLocations()) { locations.add(_insdc_location_string_ignoring_strand_and_subfeatures((AbstractLocation) l, record_length)); } @@ -223,7 +223,7 @@ private String _insdc_feature_location_string(FeatureInterface locations = new ArrayList<>(); + List locations = new ArrayList<>(); for(Location l : feature.getLocations().getSubLocations()) { locations.add(_insdc_location_string_ignoring_strand_and_subfeatures((AbstractLocation) l, record_length)); } @@ -248,7 +248,7 @@ private String _insdc_feature_location_string(FeatureInterface locations = new ArrayList<>(); + List locations = new ArrayList<>(); for(FeatureInterface, C> f : feature.getChildrenFeatures()) { locations.add(_insdc_location_string_ignoring_strand_and_subfeatures(f.getLocations(), record_length)); } @@ -261,7 +261,7 @@ private String _insdc_feature_location_string(FeatureInterface locations = new ArrayList<>(); + List locations = new ArrayList<>(); for(FeatureInterface, C> f : feature.getChildrenFeatures()) { locations.add(_insdc_location_string_ignoring_strand_and_subfeatures(f.getLocations(), record_length)); } @@ -404,16 +404,16 @@ raise ValueError("Expected a SeqFeature position object.") * @param text * @param max_len */ - protected ArrayList _split_multi_line(String text, int max_len) { + protected List _split_multi_line(String text, int max_len) { // TODO Auto-generated method stub - ArrayList output = new ArrayList<>(); + List output = new ArrayList<>(); text = text.trim(); if(text.length() <= max_len) { output.add(text); return output; } - ArrayList words = new ArrayList<>(); + List words = new ArrayList<>(); Collections.addAll(words, text.split("\\s+")); while(!words.isEmpty()) { text = words.remove(0); diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/StringProxySequenceReader.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/StringProxySequenceReader.java index 7ae1fa1632..b97ad43bb9 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/StringProxySequenceReader.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/StringProxySequenceReader.java @@ -83,7 +83,7 @@ public void setContents(String sequence) throws CompoundNotFoundException { } } - public void setContents(String sequence, ArrayList features) throws CompoundNotFoundException{ + public void setContents(String sequence, List features) throws CompoundNotFoundException{ setContents(sequence); } diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/UniprotProxySequenceReader.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/UniprotProxySequenceReader.java index 020fee4a97..f1cd7a7471 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/UniprotProxySequenceReader.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/loader/UniprotProxySequenceReader.java @@ -340,14 +340,14 @@ public AccessionID getAccession() { * @return * @throws XPathExpressionException */ - public ArrayList getAccessions() throws XPathExpressionException { - ArrayList accessionList = new ArrayList<>(); + public List getAccessions() throws XPathExpressionException { + List accessionList = new ArrayList<>(); if (uniprotDoc == null) { return accessionList; } Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); - ArrayList keyWordElementList = XMLHelper.selectElements(entryElement, "accession"); + List keyWordElementList = XMLHelper.selectElements(entryElement, "accession"); for (Element element : keyWordElementList) { AccessionID accessionID = new AccessionID(element.getTextContent(), DataSource.UNIPROT); accessionList.add(accessionID); @@ -363,7 +363,7 @@ public ArrayList getAccessions() throws XPathExpressionException { * @return * @throws XPathExpressionException */ - public ArrayList getAliases() throws XPathExpressionException { + public List getAliases() throws XPathExpressionException { return getProteinAliases(); } @@ -372,8 +372,8 @@ public ArrayList getAliases() throws XPathExpressionException { * @return * @throws XPathExpressionException */ - public ArrayList getProteinAliases() throws XPathExpressionException { - ArrayList aliasList = new ArrayList<>(); + public List getProteinAliases() throws XPathExpressionException { + List aliasList = new ArrayList<>(); if (uniprotDoc == null) { return aliasList; } @@ -381,7 +381,7 @@ public ArrayList getProteinAliases() throws XPathExpressionException { Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); Element proteinElement = XMLHelper.selectSingleElement(entryElement, "protein"); - ArrayList keyWordElementList; + List keyWordElementList; getProteinAliasesFromNameGroup(aliasList, proteinElement); keyWordElementList = XMLHelper.selectElements(proteinElement, "component"); @@ -439,9 +439,9 @@ public ArrayList getProteinAliases() throws XPathExpressionException { * @param proteinElement * @throws XPathExpressionException */ - private void getProteinAliasesFromNameGroup(ArrayList aliasList, Element proteinElement) + private void getProteinAliasesFromNameGroup(List aliasList, Element proteinElement) throws XPathExpressionException { - ArrayList keyWordElementList = XMLHelper.selectElements(proteinElement, "alternativeName"); + List keyWordElementList = XMLHelper.selectElements(proteinElement, "alternativeName"); for (Element element : keyWordElementList) { getProteinAliasesFromElement(aliasList, element); } @@ -457,7 +457,7 @@ private void getProteinAliasesFromNameGroup(ArrayList aliasList, Element * @param element * @throws XPathExpressionException */ - private void getProteinAliasesFromElement(ArrayList aliasList, Element element) + private void getProteinAliasesFromElement(List aliasList, Element element) throws XPathExpressionException { Element fullNameElement = XMLHelper.selectSingleElement(element, "fullName"); aliasList.add(fullNameElement.getTextContent()); @@ -475,16 +475,16 @@ private void getProteinAliasesFromElement(ArrayList aliasList, Element e * @return * @throws XPathExpressionException */ - public ArrayList getGeneAliases() throws XPathExpressionException { - ArrayList aliasList = new ArrayList<>(); + public List getGeneAliases() throws XPathExpressionException { + List aliasList = new ArrayList<>(); if (uniprotDoc == null) { return aliasList; } Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); - ArrayList proteinElements = XMLHelper.selectElements(entryElement, "gene"); + List proteinElements = XMLHelper.selectElements(entryElement, "gene"); for(Element proteinElement : proteinElements) { - ArrayList keyWordElementList = XMLHelper.selectElements(proteinElement, "name"); + List keyWordElementList = XMLHelper.selectElements(proteinElement, "name"); for (Element element : keyWordElementList) { aliasList.add(element.getTextContent()); } @@ -774,8 +774,8 @@ public String getOrganismName() { * @return */ @Override - public ArrayList getKeyWords() { - ArrayList keyWordsList = new ArrayList<>(); + public List getKeyWords() { + List keyWordsList = new ArrayList<>(); if (uniprotDoc == null) { return keyWordsList; } @@ -783,7 +783,7 @@ public ArrayList getKeyWords() { Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); - ArrayList keyWordElementList = XMLHelper.selectElements(entryElement, "keyword"); + List keyWordElementList = XMLHelper.selectElements(entryElement, "keyword"); for (Element element : keyWordElementList) { keyWordsList.add(element.getTextContent()); } @@ -809,7 +809,7 @@ public Map> getDatabaseReferences() { try { Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); - ArrayList dbreferenceElementList = XMLHelper.selectElements(entryElement, "dbReference"); + List dbreferenceElementList = XMLHelper.selectElements(entryElement, "dbReference"); for (Element element : dbreferenceElementList) { String type = element.getAttribute("type"); String id = element.getAttribute("id"); @@ -819,7 +819,7 @@ public Map> getDatabaseReferences() { databaseReferencesHashMap.put(type, idlist); } DBReferenceInfo dbreferenceInfo = new DBReferenceInfo(type, id); - ArrayList propertyElementList = XMLHelper.selectElements(element, "property"); + List propertyElementList = XMLHelper.selectElements(element, "property"); for (Element propertyElement : propertyElementList) { String propertyType = propertyElement.getAttribute("type"); String propertyValue = propertyElement.getAttribute("value"); diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java index 5797df9502..b5b2d29740 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java @@ -65,14 +65,14 @@ public abstract class AbstractSequence implements Sequence parentSequence = null; private String source = null; - private ArrayList notesList = new ArrayList<>(); + private List notesList = new ArrayList<>(); private Double sequenceScore = null; private FeaturesKeyWordInterface featuresKeyWord = null; private DatabaseReferenceInterface databaseReferences = null; private FeatureRetriever featureRetriever = null; - private ArrayList, C>> features = + private List, C>> features = new ArrayList<>(); - private LinkedHashMap, C>>> groupedFeatures = + private Map, C>>> groupedFeatures = new LinkedHashMap<>(); private List comments = new ArrayList<>(); private List references; @@ -139,7 +139,7 @@ public void setProxySequenceReader(SequenceReader proxyLoader) { } // success of next statement guaranteed because source is a compulsory field //DBReferenceInfo dbQualifier = (DBReferenceInfo)ff.get("source").get(0).getQualifiers().get("db_xref"); - ArrayList dbQualifiers = (ArrayList)ff.get("source").get(0).getQualifiers().get("db_xref"); + List dbQualifiers = (ArrayList)ff.get("source").get(0).getQualifiers().get("db_xref"); DBReferenceInfo dbQualifier = dbQualifiers.get(0); if (dbQualifier != null) this.setTaxonomy(new TaxonomyID(dbQualifier.getDatabase()+":"+dbQualifier.getId(), DataSource.UNKNOWN)); @@ -303,14 +303,14 @@ public void removeNote(String note) { /** * @return the notesList */ - public ArrayList getNotesList() { + public List getNotesList() { return notesList; } /** * @param notesList the notesList to set */ - public void setNotesList(ArrayList notesList) { + public void setNotesList(List notesList) { this.notesList = notesList; } @@ -353,7 +353,7 @@ public void setReferences(List references) { * @return */ public List, C>> getFeatures(String featureType, int bioSequencePosition) { - ArrayList, C>> featureHits = + List, C>> featureHits = new ArrayList<>(); List, C>> features = getFeaturesByType(featureType); if (features != null) { @@ -372,7 +372,7 @@ public List, C>> getFeatures(String feature * @return */ public List, C>> getFeatures(int bioSequencePosition) { - ArrayList, C>> featureHits = + List, C>> featureHits = new ArrayList<>(); if (features != null) { for (FeatureInterface, C> feature : features) { @@ -414,7 +414,7 @@ public void addFeature(int bioStart, int bioEnd, FeatureInterface, C> feature) { features.add(feature); - ArrayList, C>> featureList = groupedFeatures.get(feature.getType()); + List, C>> featureList = groupedFeatures.get(feature.getType()); if (featureList == null) { featureList = new ArrayList<>(); groupedFeatures.put(feature.getType(), featureList); @@ -430,7 +430,7 @@ public void addFeature(FeatureInterface, C> feature) { */ public void removeFeature(FeatureInterface, C> feature) { features.remove(feature); - ArrayList, C>> featureList = groupedFeatures.get(feature.getType()); + List, C>> featureList = groupedFeatures.get(feature.getType()); if (featureList != null) { featureList.remove(feature); if (featureList.isEmpty()) { diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/util/SingleLinkageClusterer.java b/biojava-core/src/main/java/org/biojava/nbio/core/util/SingleLinkageClusterer.java index 1b395828b5..ad252374d9 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/util/SingleLinkageClusterer.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/util/SingleLinkageClusterer.java @@ -87,7 +87,7 @@ public String toString() { //private Set toSkip; - private ArrayList indicesToCheck; + private List indicesToCheck; /** diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/util/XMLHelper.java b/biojava-core/src/main/java/org/biojava/nbio/core/util/XMLHelper.java index 4344063e1d..64aee3849a 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/util/XMLHelper.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/util/XMLHelper.java @@ -44,6 +44,7 @@ import static org.biojava.nbio.core.sequence.io.util.IOUtils.close; import static org.biojava.nbio.core.sequence.io.util.IOUtils.openFile; +import java.util.List; /** * Helper methods to simplify boilerplate XML parsing code for {@code}org.w3c.dom{@code} XML objects @@ -206,8 +207,8 @@ public static Element selectSingleElement(Element element, String xpathExpressio * @return A possibly empty but non-null {@code}ArrayList{@code} * @throws XPathExpressionException */ - public static ArrayList selectElements(Element element, String xpathExpression) throws XPathExpressionException { - ArrayList resultVector = new ArrayList<>(); + public static List selectElements(Element element, String xpathExpression) throws XPathExpressionException { + List resultVector = new ArrayList<>(); if (element == null) { return resultVector; } diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/fasta/TestFASTAReader.java b/biojava-core/src/test/java/org/biojava/nbio/core/fasta/TestFASTAReader.java index 75992962d1..e8a9d34ec9 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/fasta/TestFASTAReader.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/fasta/TestFASTAReader.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.util.LinkedHashMap; +import java.util.Map; import static org.junit.Assert.* ; import static org.hamcrest.CoreMatchers.* ; @@ -46,7 +47,7 @@ private void testProcessAll(String path) throws Exception { inStream, new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); - LinkedHashMap sequences = fastaReader.process(); + Map sequences = fastaReader.process(); assertThat(sequences,is(notNullValue())); assertThat(sequences.size(),is(1)); assertThat(sequences.containsKey("P02768"),is(true)); @@ -86,12 +87,12 @@ private void testProcess1(String path) throws Exception { inStream, new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); - LinkedHashMap out1 = fastaReader.process(1); + Map out1 = fastaReader.process(1); assertThat(out1,is(notNullValue())); assertThat(out1.size(),is(1)); assertThat(out1.containsKey("P02768"),is(true)); assertThat(out1.get("P02768").getLength(),is(609)); - LinkedHashMap out2 = fastaReader.process(1); + Map out2 = fastaReader.process(1); assertThat(out2,is(nullValue())); } finally { if(fastaReader != null) fastaReader.close(); @@ -128,17 +129,17 @@ private void testProcess2(String path) throws Exception { inStream, new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); - LinkedHashMap out1 = fastaReader.process(1); + Map out1 = fastaReader.process(1); assertThat(out1,is(notNullValue())); assertThat(out1.size(),is(1)); assertThat(out1.containsKey("P02768"),is(true)); assertThat(out1.get("P02768").getLength(),is(609)); - LinkedHashMap out2 = fastaReader.process(1); + Map out2 = fastaReader.process(1); assertThat(out2,is(notNullValue())); assertThat(out2.size(),is(1)); assertThat(out2.containsKey("P00698"),is(true)); assertThat(out2.get("P00698").getLength(),is(147)); - LinkedHashMap out3 = fastaReader.process(1); + Map out3 = fastaReader.process(1); assertThat(out3,is(nullValue())); } finally { if(fastaReader != null) fastaReader.close(); diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/GeneSequenceTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/GeneSequenceTest.java index ecb1e7d1b2..e2cb30459a 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/GeneSequenceTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/GeneSequenceTest.java @@ -129,7 +129,7 @@ void returnedIntronCollectionsAreNotMutable() throws Exception { geneSequence.addExon(new AccessionID("a"), 20, 50); geneSequence.addExon(new AccessionID("b"), 80, 100); geneSequence.addIntronsUsingExons(); - ArrayList introns = geneSequence.getIntronSequences(); + List introns = geneSequence.getIntronSequences(); assertEquals(1, introns.size()); introns.remove(0); assertEquals(1, geneSequence.getIntronSequences().size()); diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/FastaReaderTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/FastaReaderTest.java index 0222b54c47..7981d8e6e3 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/FastaReaderTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/FastaReaderTest.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.LinkedHashMap; +import java.util.Map; import java.util.logging.Level; /** @@ -70,7 +71,7 @@ public void testProcess() throws Exception { FastaReader fastaReader = new FastaReader(inStream, new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); - LinkedHashMap proteinSequences = fastaReader.process(); + Map proteinSequences = fastaReader.process(); inStream.close(); //Should have 282 sequences @@ -107,7 +108,7 @@ public void processIntTest() throws Exception { InputStream inStream = this.getClass().getResourceAsStream("/PF00104_small.fasta"); Assert.assertNotNull(inStream); FastaReader fastaReader = new FastaReader(inStream, new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); - LinkedHashMap proteinSequences = fastaReader.process(200); + Map proteinSequences = fastaReader.process(200); //Should have 200 sequences //logger.debug("Expecting 200 got " + proteinSequences.size()); @@ -169,7 +170,7 @@ public void testSmallFasta() throws IOException { new GenericFastaHeaderParser(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet())); - LinkedHashMap b; + Map b; int nrSeq = 0; @@ -200,7 +201,7 @@ public void testSmallFasta2() throws IOException { int nrSeq = 0; - LinkedHashMap b = fastaReader.process(); + Map b = fastaReader.process(); Assert.assertNotNull(b); diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankCookbookTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankCookbookTest.java index d6018a5eaf..132a36d816 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankCookbookTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankCookbookTest.java @@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory; import java.util.LinkedHashMap; +import java.util.Map; /** * @@ -90,12 +91,12 @@ public void testProcess() throws Throwable { //File protFile = new File("src/test/resources/BondFeature.gb"); ClasspathResource protResource = new ClasspathResource("BondFeature.gb"); - LinkedHashMap dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaResource.getInputStream()); + Map dnaSequences = GenbankReaderHelper.readGenbankDNASequence(dnaResource.getInputStream()); for (DNASequence sequence : dnaSequences.values()) { logger.debug("DNA Sequence: {}", sequence.getSequenceAsString()); } - LinkedHashMap protSequences = GenbankReaderHelper.readGenbankProteinSequence(protResource.getInputStream()); + Map protSequences = GenbankReaderHelper.readGenbankProteinSequence(protResource.getInputStream()); for (ProteinSequence sequence : protSequences.values()) { logger.debug("Protein Sequence: {}", sequence.getSequenceAsString()); } diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java index 325e07a5ef..e813f863a8 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java @@ -68,7 +68,7 @@ public void testProcess() throws Exception { new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()) ); - LinkedHashMap proteinSequences = genbankProtein.process(); + Map proteinSequences = genbankProtein.process(); assertThat(proteinSequences.get("NP_000257").getComments().get(0),is( "VALIDATED REFSEQ: This record has undergone validation or\n" + @@ -114,7 +114,7 @@ public void testProcess() throws Exception { new GenericGenbankHeaderParser<>(), new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()) ); - LinkedHashMap dnaSequences = genbankDNA.process(); + Map dnaSequences = genbankDNA.process(); assertNotNull(dnaSequences); assertEquals(1, dnaSequences.size()); @@ -144,7 +144,7 @@ public void testPartialProcess() throws IOException, CompoundNotFoundException { ); // First call to process(1) returns the first sequence - LinkedHashMap dnaSequences = genbankDNA.process(1); + Map dnaSequences = genbankDNA.process(1); assertFalse(inStream.isclosed()); assertNotNull(dnaSequences); @@ -177,7 +177,7 @@ public void CDStest() throws Exception { new GenericGenbankHeaderParser<>(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()) ); - LinkedHashMap proteinSequences = GenbankProtein.process(); + Map proteinSequences = GenbankProtein.process(); assertTrue(inStream.isclosed()); @@ -206,7 +206,7 @@ private DNASequence readGenbankResource(final String resource) throws IOExceptio new GenericGenbankHeaderParser<>(), new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()) ); - LinkedHashMap dnaSequences = genbankDNA.process(); + Map dnaSequences = genbankDNA.process(); return dnaSequences.values().iterator().next(); } @@ -218,7 +218,7 @@ private RNASequence readGenbankRNAResource(final String resource) throws IOExcep new GenericGenbankHeaderParser<>(), new RNASequenceCreator(RNACompoundSet.getRNACompoundSet()) ); - LinkedHashMap rnaSequences = genbankRNA.process(); + Map rnaSequences = genbankRNA.process(); return rnaSequences.values().iterator().next(); } @@ -230,7 +230,7 @@ private ProteinSequence readGenbankProteinResource(final String resource) throws new GenericGenbankHeaderParser<>(), new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()) ); - LinkedHashMap proteinSequences = genbankProtein.process(); + Map proteinSequences = genbankProtein.process(); return proteinSequences.values().iterator().next(); } @@ -346,7 +346,7 @@ public void testGithub843() throws Exception { new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()) ); - LinkedHashMap dnaSequences = genbankDNA.process(); + Map dnaSequences = genbankDNA.process(); assertNotNull(dnaSequences); DNASequence dna = new ArrayList<>(dnaSequences.values()).get(0); diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankWriterTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankWriterTest.java index cdd466f6f0..0eb3995046 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankWriterTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankWriterTest.java @@ -63,7 +63,7 @@ public void testProcess() throws Exception { InputStream inStream = GenbankWriterTest.class.getResourceAsStream("/NM_000266.gb"); //File dnaFile = new File("src/test/resources/NM_000266.gb"); - LinkedHashMap dnaSequences = GenbankReaderHelper.readGenbankDNASequence( inStream ); + Map dnaSequences = GenbankReaderHelper.readGenbankDNASequence( inStream ); ByteArrayOutputStream fragwriter = new ByteArrayOutputStream(); ArrayList seqs = new ArrayList(); for(DNASequence seq : dnaSequences.values()) { diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/util/XMLHelperTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/util/XMLHelperTest.java index 0a9ace033f..d9eb23589d 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/util/XMLHelperTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/util/XMLHelperTest.java @@ -12,6 +12,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.List; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -148,7 +149,7 @@ void before() throws SAXException, IOException, ParserConfigurationException { @Test void selectMultipleElementsWithXPath() throws XPathExpressionException { - ArrayList selected = XMLHelper.selectElements(root, "/root/list/a"); + List selected = XMLHelper.selectElements(root, "/root/list/a"); assertEquals(2, selected.size()); } @@ -157,7 +158,7 @@ void selectMultipleElementsWithXPathSearchesWholeTree() throws XPathExpressionException { Element a1 = (Element) doc.getElementsByTagName("a").item(0); - ArrayList selected = XMLHelper.selectElements(a1, "/root"); + List selected = XMLHelper.selectElements(a1, "/root"); assertEquals(1, selected.size()); assertEquals("root", selected.get(0).getTagName()); } diff --git a/biojava-genome/src/main/java/org/biojava/nbio/genome/GeneFeatureHelper.java b/biojava-genome/src/main/java/org/biojava/nbio/genome/GeneFeatureHelper.java index 681ddb0910..0090ce7786 100644 --- a/biojava-genome/src/main/java/org/biojava/nbio/genome/GeneFeatureHelper.java +++ b/biojava-genome/src/main/java/org/biojava/nbio/genome/GeneFeatureHelper.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.Map; /** * @@ -43,7 +44,7 @@ public class GeneFeatureHelper { static public LinkedHashMap loadFastaAddGeneFeaturesFromUpperCaseExonFastaFile(File fastaSequenceFile, File uppercaseFastaFile, boolean throwExceptionGeneNotFound) throws Exception { LinkedHashMap chromosomeSequenceList = new LinkedHashMap<>(); - LinkedHashMap dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); + Map dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); for (String accession : dnaSequenceList.keySet()) { DNASequence contigSequence = dnaSequenceList.get(accession); ChromosomeSequence chromsomeSequence = new ChromosomeSequence(contigSequence.getSequenceAsString()); @@ -52,7 +53,7 @@ static public LinkedHashMap loadFastaAddGeneFeatures } - LinkedHashMap geneSequenceList = FastaReaderHelper.readFastaDNASequence(uppercaseFastaFile); + Map geneSequenceList = FastaReaderHelper.readFastaDNASequence(uppercaseFastaFile); for (DNASequence dnaSequence : geneSequenceList.values()) { String geneSequence = dnaSequence.getSequenceAsString(); String lcGeneSequence = geneSequence.toLowerCase(); @@ -162,7 +163,7 @@ static public LinkedHashMap loadFastaAddGeneFeatures * @throws Exception */ static public void outputFastaSequenceLengthGFF3(File fastaSequenceFile, File gffFile) throws Exception { - LinkedHashMap dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); + Map dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); String fileName = fastaSequenceFile.getName(); FileWriter fw = new FileWriter(gffFile); String newLine = System.getProperty("line.separator"); @@ -182,9 +183,9 @@ static public void outputFastaSequenceLengthGFF3(File fastaSequenceFile, File gf * @return * @throws Exception */ - static public LinkedHashMap loadFastaAddGeneFeaturesFromGeneIDGFF2(File fastaSequenceFile, File gffFile) throws Exception { - LinkedHashMap dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); - LinkedHashMap chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); + static public Map loadFastaAddGeneFeaturesFromGeneIDGFF2(File fastaSequenceFile, File gffFile) throws Exception { + Map dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); + Map chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); FeatureList listGenes = GeneIDGFF2Reader.read(gffFile.getAbsolutePath()); addGeneIDGFF2GeneFeatures(chromosomeSequenceList, listGenes); return chromosomeSequenceList; @@ -197,7 +198,7 @@ static public LinkedHashMap loadFastaAddGeneFeatures * @param listGenes * @throws Exception */ - static public void addGeneIDGFF2GeneFeatures(LinkedHashMap chromosomeSequenceList, FeatureList listGenes) throws Exception { + static public void addGeneIDGFF2GeneFeatures(Map chromosomeSequenceList, FeatureList listGenes) throws Exception { Collection geneIds = listGenes.attributeValues("gene_id"); for (String geneid : geneIds) { FeatureList gene = listGenes.selectByAttribute("gene_id", geneid); @@ -313,7 +314,7 @@ static public void addGeneIDGFF2GeneFeatures(LinkedHashMap getChromosomeSequenceFromDNASequence(LinkedHashMap dnaSequenceList) { + static public Map getChromosomeSequenceFromDNASequence(Map dnaSequenceList) { LinkedHashMap chromosomeSequenceList = new LinkedHashMap<>(); for (String key : dnaSequenceList.keySet()) { DNASequence dnaSequence = dnaSequenceList.get(key); @@ -334,9 +335,9 @@ static public LinkedHashMap getChromosomeSequenceFro * @return * @throws Exception */ - static public LinkedHashMap loadFastaAddGeneFeaturesFromGmodGFF3(File fastaSequenceFile, File gffFile,boolean lazyloadsequences) throws Exception { - LinkedHashMap dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile,lazyloadsequences); - LinkedHashMap chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); + static public Map loadFastaAddGeneFeaturesFromGmodGFF3(File fastaSequenceFile, File gffFile,boolean lazyloadsequences) throws Exception { + Map dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile,lazyloadsequences); + Map chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); FeatureList listGenes = GFF3Reader.read(gffFile.getAbsolutePath()); addGmodGFF3GeneFeatures(chromosomeSequenceList, listGenes); return chromosomeSequenceList; @@ -348,7 +349,7 @@ static public LinkedHashMap loadFastaAddGeneFeatures * @param listGenes * @throws Exception */ - static public void addGmodGFF3GeneFeatures(LinkedHashMap chromosomeSequenceList, FeatureList listGenes) throws Exception { + static public void addGmodGFF3GeneFeatures(Map chromosomeSequenceList, FeatureList listGenes) throws Exception { // key off mRNA as being a known feature that may or may not have a parent gene @@ -532,15 +533,15 @@ static public void addGmodGFF3GeneFeatures(LinkedHashMap loadFastaAddGeneFeaturesFromGlimmerGFF3(File fastaSequenceFile, File gffFile) throws Exception { - LinkedHashMap dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); - LinkedHashMap chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); + static public Map loadFastaAddGeneFeaturesFromGlimmerGFF3(File fastaSequenceFile, File gffFile) throws Exception { + Map dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); + Map chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); FeatureList listGenes = GFF3Reader.read(gffFile.getAbsolutePath()); addGlimmerGFF3GeneFeatures(chromosomeSequenceList, listGenes); return chromosomeSequenceList; } - static public void addGlimmerGFF3GeneFeatures(LinkedHashMap chromosomeSequenceList, FeatureList listGenes) throws Exception { + static public void addGlimmerGFF3GeneFeatures(Map chromosomeSequenceList, FeatureList listGenes) throws Exception { FeatureList mRNAFeatures = listGenes.selectByType("mRNA"); for (FeatureI f : mRNAFeatures) { Feature mRNAFeature = (Feature) f; @@ -677,15 +678,15 @@ static public void addGlimmerGFF3GeneFeatures(LinkedHashMap loadFastaAddGeneFeaturesFromGeneMarkGTF(File fastaSequenceFile, File gffFile) throws Exception { - LinkedHashMap dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); - LinkedHashMap chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); + static public Map loadFastaAddGeneFeaturesFromGeneMarkGTF(File fastaSequenceFile, File gffFile) throws Exception { + Map dnaSequenceList = FastaReaderHelper.readFastaDNASequence(fastaSequenceFile); + Map chromosomeSequenceList = GeneFeatureHelper.getChromosomeSequenceFromDNASequence(dnaSequenceList); FeatureList listGenes = GeneMarkGTFReader.read(gffFile.getAbsolutePath()); addGeneMarkGTFGeneFeatures(chromosomeSequenceList, listGenes); return chromosomeSequenceList; } - static public void addGeneMarkGTFGeneFeatures(LinkedHashMap chromosomeSequenceList, FeatureList listGenes) throws Exception { + static public void addGeneMarkGTFGeneFeatures(Map chromosomeSequenceList, FeatureList listGenes) throws Exception { Collection geneIds = listGenes.attributeValues("gene_id"); for (String geneid : geneIds) { // if(geneid.equals("45_g")){ diff --git a/biojava-genome/src/main/java/org/biojava/nbio/genome/homology/GFF3FromUniprotBlastHits.java b/biojava-genome/src/main/java/org/biojava/nbio/genome/homology/GFF3FromUniprotBlastHits.java index e8d7666348..bc6893d19d 100644 --- a/biojava-genome/src/main/java/org/biojava/nbio/genome/homology/GFF3FromUniprotBlastHits.java +++ b/biojava-genome/src/main/java/org/biojava/nbio/genome/homology/GFF3FromUniprotBlastHits.java @@ -87,7 +87,7 @@ public void process(LinkedHashMap> hits, LinkedHashMap String predictedProteinSequence = transcriptSequence.getProteinSequence().getSequenceAsString(); - ArrayList cdsProteinList = transcriptSequence.getProteinCDSSequences(); + List cdsProteinList = transcriptSequence.getProteinCDSSequences(); ArrayList cdsSequenceList = new ArrayList<>(transcriptSequence.getCDSSequences().values()); String testSequence = ""; @@ -228,7 +228,7 @@ PairwiseSequenceAlignerType.LOCAL, new SimpleGapPenalty(), for (DBReferenceInfo note : goList) { notes = notes + " " + note.getId(); geneSequence.addNote(note.getId()); // add note/keyword which can be output in fasta header if needed - LinkedHashMap properties = note.getProperties(); + Map properties = note.getProperties(); for (String propertytype : properties.keySet()) { if ("evidence".equals(propertytype)) { continue; @@ -292,7 +292,7 @@ public static void main(String[] args) { */ try { - LinkedHashMap dnaSequenceHashMap = GeneFeatureHelper.loadFastaAddGeneFeaturesFromGlimmerGFF3(new File("/Users/Scooter/scripps/dyadic/analysis/454Scaffolds/454Scaffolds-16.fna"), new File("/Users/Scooter/scripps/dyadic/GlimmerHMM/c1_glimmerhmm-16.gff")); + Map dnaSequenceHashMap = GeneFeatureHelper.loadFastaAddGeneFeaturesFromGlimmerGFF3(new File("/Users/Scooter/scripps/dyadic/analysis/454Scaffolds/454Scaffolds-16.fna"), new File("/Users/Scooter/scripps/dyadic/GlimmerHMM/c1_glimmerhmm-16.gff")); LinkedHashMap geneSequenceList = GeneFeatureHelper.getGeneSequences(dnaSequenceHashMap.values()); FileOutputStream fo = new FileOutputStream("/Users/Scooter/scripps/dyadic/outputGlimmer/genemark_uniprot_match-16.gff3"); LinkedHashMap> blasthits = BlastHomologyHits.getMatches(new File("/Users/Scooter/scripps/dyadic/blastresults/c1_glimmer_in_uniprot.xml"), 1E-10); diff --git a/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/geneid/GeneIDXMLReader.java b/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/geneid/GeneIDXMLReader.java index b509f73ab7..b68074e080 100644 --- a/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/geneid/GeneIDXMLReader.java +++ b/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/geneid/GeneIDXMLReader.java @@ -33,6 +33,7 @@ import java.io.File; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.List; /** * @@ -52,7 +53,7 @@ public GeneIDXMLReader(String geneidXMLFile) throws Exception { public LinkedHashMap getProteinSequences() throws Exception { LinkedHashMap proteinSequenceList = new LinkedHashMap<>(); - ArrayList elementList = XMLHelper.selectElements(geneidDoc.getDocumentElement(), "prediction/gene/protein"); + List elementList = XMLHelper.selectElements(geneidDoc.getDocumentElement(), "prediction/gene/protein"); logger.info("{} hits", elementList.size()); for (Element proteinElement : elementList) { @@ -69,7 +70,7 @@ public LinkedHashMap getProteinSequences() throws Excep public LinkedHashMap getDNACodingSequences() throws Exception { LinkedHashMap dnaSequenceList = new LinkedHashMap<>(); - ArrayList elementList = XMLHelper.selectElements(geneidDoc.getDocumentElement(), "prediction/gene/cDNA"); + List elementList = XMLHelper.selectElements(geneidDoc.getDocumentElement(), "prediction/gene/cDNA"); logger.info("{} hits", elementList.size()); for (Element dnaElement : elementList) { diff --git a/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/GFF3Writer.java b/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/GFF3Writer.java index 4d5980fa23..7432729d97 100644 --- a/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/GFF3Writer.java +++ b/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/GFF3Writer.java @@ -26,6 +26,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * @@ -39,7 +41,7 @@ public class GFF3Writer { * @param chromosomeSequenceList * @throws Exception */ - public void write(OutputStream outputStream, LinkedHashMap chromosomeSequenceList) throws Exception { + public void write(OutputStream outputStream, Map chromosomeSequenceList) throws Exception { outputStream.write("##gff-version 3\n".getBytes()); for (String key : chromosomeSequenceList.keySet()) { @@ -117,7 +119,7 @@ public void write(OutputStream outputStream, LinkedHashMap notesList) { + private String getGFF3Note(List notesList) { String notes = ""; if (notesList.size() > 0) { diff --git a/biojava-genome/src/main/java/org/biojava/nbio/genome/query/BlastXMLQuery.java b/biojava-genome/src/main/java/org/biojava/nbio/genome/query/BlastXMLQuery.java index 3f3cccf654..06d65933a9 100644 --- a/biojava-genome/src/main/java/org/biojava/nbio/genome/query/BlastXMLQuery.java +++ b/biojava-genome/src/main/java/org/biojava/nbio/genome/query/BlastXMLQuery.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.List; /** * @@ -49,19 +50,19 @@ public BlastXMLQuery(String blastFile) throws Exception { public LinkedHashMap> getHitsQueryDef(double maxEScore) throws Exception { LinkedHashMap> hitsHashMap = new LinkedHashMap<>(); logger.info("Query for hits"); - ArrayList elementList = XMLHelper.selectElements(blastDoc.getDocumentElement(), "BlastOutput_iterations/Iteration[Iteration_hits]"); + List elementList = XMLHelper.selectElements(blastDoc.getDocumentElement(), "BlastOutput_iterations/Iteration[Iteration_hits]"); logger.info("{} hits", elementList.size()); for (Element element : elementList) { Element iterationquerydefElement = XMLHelper.selectSingleElement(element, "Iteration_query-def"); String querydef = iterationquerydefElement.getTextContent(); Element iterationHitsElement = XMLHelper.selectSingleElement(element, "Iteration_hits"); - ArrayList hitList = XMLHelper.selectElements(iterationHitsElement, "Hit"); + List hitList = XMLHelper.selectElements(iterationHitsElement, "Hit"); for (Element hitElement : hitList) { Element hitaccessionElement = XMLHelper.selectSingleElement(hitElement, "Hit_accession"); String hitaccession = hitaccessionElement.getTextContent(); Element hithspsElement = XMLHelper.selectSingleElement(hitElement, "Hit_hsps"); - ArrayList hspList = XMLHelper.selectElements(hithspsElement, "Hsp"); + List hspList = XMLHelper.selectElements(hithspsElement, "Hsp"); for (Element hspElement : hspList) { Element evalueElement = XMLHelper.selectSingleElement(hspElement, "Hsp_evalue"); String value = evalueElement.getTextContent(); diff --git a/biojava-genome/src/main/java/org/biojava/nbio/genome/util/SplitFasta.java b/biojava-genome/src/main/java/org/biojava/nbio/genome/util/SplitFasta.java index 9018749f33..374dd378a1 100644 --- a/biojava-genome/src/main/java/org/biojava/nbio/genome/util/SplitFasta.java +++ b/biojava-genome/src/main/java/org/biojava/nbio/genome/util/SplitFasta.java @@ -30,6 +30,7 @@ import java.io.File; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.Map; /** @@ -44,7 +45,7 @@ public void processNucleotides(File fastaFileName,String uniqueid, File outputDi if(!outputDirectory.exists()) outputDirectory.mkdirs(); - LinkedHashMap dnaSequenceHashMap = FastaReaderHelper.readFastaDNASequence(fastaFileName); + Map dnaSequenceHashMap = FastaReaderHelper.readFastaDNASequence(fastaFileName); for(DNASequence dnaSequence : dnaSequenceHashMap.values()){ String fileName = outputDirectory.getAbsolutePath() + File.separatorChar; if(uniqueid.length() > 0){ diff --git a/biojava-genome/src/test/java/org/biojava/nbio/genome/GeneFeatureHelperTest.java b/biojava-genome/src/test/java/org/biojava/nbio/genome/GeneFeatureHelperTest.java index ba0a5d21a3..e5e1a8379d 100644 --- a/biojava-genome/src/test/java/org/biojava/nbio/genome/GeneFeatureHelperTest.java +++ b/biojava-genome/src/test/java/org/biojava/nbio/genome/GeneFeatureHelperTest.java @@ -39,6 +39,7 @@ import java.nio.file.Files; import java.util.Collection; import java.util.LinkedHashMap; +import java.util.Map; /** * @@ -112,7 +113,7 @@ public void testOutputFastaSequenceLengthGFF3() throws Exception { @Test public void testAddGFF3Note() throws Exception { - LinkedHashMap chromosomeSequenceList = GeneFeatureHelper + Map chromosomeSequenceList = GeneFeatureHelper .loadFastaAddGeneFeaturesFromGmodGFF3(new File("src/test/resources/volvox_all.fna"), new File( "src/test/resources/volvox.gff3"), false); ChromosomeSequence ctgASequence = chromosomeSequenceList.get("ctgA"); @@ -128,10 +129,10 @@ public void testAddGFF3Note() throws Exception { */ @Test public void testGetProteinSequences() throws Exception { - LinkedHashMap chromosomeSequenceList = GeneFeatureHelper + Map chromosomeSequenceList = GeneFeatureHelper .loadFastaAddGeneFeaturesFromGmodGFF3(new File("src/test/resources/volvox_all.fna"), new File( "src/test/resources/volvox.gff3"), false); - LinkedHashMap proteinSequenceList = GeneFeatureHelper + Map proteinSequenceList = GeneFeatureHelper .getProteinSequences(chromosomeSequenceList.values()); // for(ProteinSequence proteinSequence : proteinSequenceList.values()){ // logger.info("Output={}", proteinSequence.getSequenceAsString()); @@ -149,10 +150,10 @@ public void testGetProteinSequences() throws Exception { @Test public void testGetGeneSequences() throws Exception { // logger.info("getGeneSequences"); - LinkedHashMap chromosomeSequenceList = GeneFeatureHelper + Map chromosomeSequenceList = GeneFeatureHelper .loadFastaAddGeneFeaturesFromGmodGFF3(new File("src/test/resources/volvox_all.fna"), new File( "src/test/resources/volvox.gff3"), true); - LinkedHashMap geneSequenceHashMap = GeneFeatureHelper + Map geneSequenceHashMap = GeneFeatureHelper .getGeneSequences(chromosomeSequenceList.values()); Collection geneSequences = geneSequenceHashMap.values(); diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaAFPChainConverter.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaAFPChainConverter.java index b0a8ab0bfb..81bf601ab6 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaAFPChainConverter.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaAFPChainConverter.java @@ -87,7 +87,7 @@ public static AFPChain cpFastaToAfpChain(File fastaFile, Structure structure, in SequenceCreatorInterface creator = new CasePreservingProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()); SequenceHeaderParserInterface headerParser = new GenericFastaHeaderParser<>(); FastaReader fastaReader = new FastaReader<>(inStream, headerParser, creator); - LinkedHashMap sequences = fastaReader.process(); + Map sequences = fastaReader.process(); inStream.close(); Iterator iter = sequences.values().iterator(); ProteinSequence first = iter.next(); @@ -199,7 +199,7 @@ public static AFPChain fastaFileToAfpChain(File fastaFile, Structure structure1, SequenceHeaderParserInterface headerParser = new GenericFastaHeaderParser<>(); FastaReader fastaReader = new FastaReader<>( inStream, headerParser, creator); - LinkedHashMap sequences = fastaReader.process(); + Map sequences = fastaReader.process(); inStream.close(); return fastaToAfpChain(sequences, structure1, structure2); } diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaStructureParser.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaStructureParser.java index 29baf9d825..0586df8ced 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaStructureParser.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FastaStructureParser.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.LinkedHashMap; +import java.util.Map; /** @@ -109,7 +110,7 @@ public FastaStructureParser(FastaReader read */ public void process() throws IOException, StructureException { if(sequences == null) { // only process once, then return cached values - LinkedHashMap sequenceMap = reader.process(); + Map sequenceMap = reader.process(); sequences = sequenceMap.values().toArray(new ProteinSequence[0]); accessions = new String[sequences.length];