Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private static void readInputAndGenerateOutput(String outputLocation, List<Chara
else
output = System.out;
printHeader(output, propertyList, specificList, delimiter);
LinkedHashMap<String, ProteinSequence> a = readInputFile(inputLocation, aaTable);
Map<String, ProteinSequence> a = readInputFile(inputLocation, aaTable);
//Need for the last sequence
for(Entry<String, ProteinSequence> entry:a.entrySet()){
compute(output, entry.getValue().getOriginalHeader(), entry.getValue().getSequenceAsString().trim(), delimiter, aaTable, propertyList, specificList,
Expand Down Expand Up @@ -169,15 +169,15 @@ public static void run(String[] args) throws Exception{
readInputAndGenerateOutput(outputLocation, propertyList, specificList, delimiter, inputLocation, aaTable, decimalPlace);
}

private static LinkedHashMap<String, ProteinSequence> readInputFile(String inputLocation, AminoAcidCompositionTable aaTable) throws Exception{
private static Map<String, ProteinSequence> readInputFile(String inputLocation, AminoAcidCompositionTable aaTable) throws Exception{
FileInputStream inStream = new FileInputStream(inputLocation);
CompoundSet<AminoAcidCompound> set;
if(aaTable == null){
set = CaseFreeAminoAcidCompoundSet.getAminoAcidCompoundSet();
}else{
set = aaTable.getAminoAcidCompoundSet();
}
LinkedHashMap<String, ProteinSequence> ret;
Map<String, ProteinSequence> ret;
if ( inputLocation.toLowerCase().contains(".gb")) {
GenbankReader<ProteinSequence, AminoAcidCompound> genbankReader = new GenbankReader<>(
inStream, new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(),
Expand Down
3 changes: 2 additions & 1 deletion biojava-alignment/src/main/java/demo/DemoDistanceTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,7 +65,7 @@ public static void main(String[] args) throws Exception {
new ProteinSequenceCreator(AminoAcidCompoundSet
.getAminoAcidCompoundSet()));

LinkedHashMap<String, ProteinSequence> proteinSequences =
Map<String, ProteinSequence> proteinSequences =
fastaReader.process();

inStream.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class TestDNAAlignment {

Expand Down Expand Up @@ -75,7 +76,7 @@ public void testDNAAlignment() {
private static List<DNASequence> getDNAFASTAFile() throws Exception {

InputStream inStream = TestDNAAlignment.class.getResourceAsStream(String.format("/dna-fasta.txt"));
LinkedHashMap<String, DNASequence> fastas = FastaReaderHelper.readFastaDNASequence(inStream);
Map<String, DNASequence> fastas = FastaReaderHelper.readFastaDNASequence(inStream);

List<DNASequence> sequences = new ArrayList<DNASequence>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void testMSAconversion() throws Exception {
new ProteinSequenceCreator(AminoAcidCompoundSet
.getAminoAcidCompoundSet()));

LinkedHashMap<String, ProteinSequence> proteinSequences = fastaReader
Map<String, ProteinSequence> proteinSequences = fastaReader
.process();

inStream.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, DNASequence> dnaSequences = proxy.process();
Map<String, DNASequence> dnaSequences = proxy.process();

// Initialize the Transcription Engine
TranscriptionEngine engine = new
Expand Down
4 changes: 3 additions & 1 deletion biojava-core/src/main/java/demo/ParseFastaFileDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,7 +101,7 @@ public static void main(String[] args) throws Exception {
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));

LinkedHashMap<String, ProteinSequence> b;
Map<String, ProteinSequence> b;

int nrSeq = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -46,7 +47,7 @@ public abstract class Result implements Iterable<Hit>{
private String reference;
private String dbFile;

private HashMap<String,String> programSpecificParameters;
private Map<String, String> programSpecificParameters;

private int iterationNumber;
private String queryID;
Expand All @@ -56,7 +57,7 @@ public abstract class Result implements Iterable<Hit>{
private List<Hit> hits;
private int hitCounter = -1;

public Result(String program, String version, String reference, String dbFile, HashMap<String, String> programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List<Hit> hits, Sequence querySequence) {
public Result(String program, String version, String reference, String dbFile, Map<String, String> programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List<Hit> hits, Sequence querySequence) {
this.program = program;
this.version = version;
this.reference = reference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.ServiceLoader;
import java.util.NoSuchElementException;
import java.util.Map;

/**
* Designed by Paolo Pavan.
Expand All @@ -39,7 +40,7 @@
*/

public class SearchIO implements Iterable<Result>{
static private HashMap<String,ResultFactory> extensionFactoryAssociation;
static private Map<String, ResultFactory> extensionFactoryAssociation;

final private ResultFactory factory;
final private File file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -39,7 +40,7 @@
*
*/
public class BlastResult extends Result{
public BlastResult(String program, String version, String reference, String dbFile, HashMap<String, String> programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List<Hit> hits, Sequence querySequence) {
public BlastResult(String program, String version, String reference, String dbFile, Map<String, String> programSpecificParameters, int iterationNumber, String queryID, String queryDef, int queryLength, List<Hit> hits, Sequence querySequence) {
super(program, version, reference, dbFile, programSpecificParameters, iterationNumber, queryID, queryDef, queryLength, hits, querySequence);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -39,7 +40,7 @@ public class BlastResultBuilder {
private String version;
private String reference;
private String dbFile;
private HashMap<String, String> programSpecificParameters;
private Map<String, String> programSpecificParameters;
private int iterationNumber;
private String queryID;
private String queryDef;
Expand Down Expand Up @@ -70,7 +71,7 @@ public BlastResultBuilder setDbFile(String dbFile) {
return this;
}

public BlastResultBuilder setProgramSpecificParameters(HashMap<String, String> programSpecificParameters) {
public BlastResultBuilder setProgramSpecificParameters(Map<String, String> programSpecificParameters) {
this.programSpecificParameters = programSpecificParameters;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -71,7 +72,7 @@ private enum PARSING_CONSISTENCY {

// data imported private:
int queryIdNumber = 0;
HashMap<String,String> queryIdMapping = new HashMap<>();
Map<String, String> queryIdMapping = new HashMap<>();
String programName=null, queryName = null, databaseFile = null;
private String queryId ;
private String subjectId ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
// create mappings between sequences and blast id
mapIds();

ArrayList<Result> resultsCollection;
ArrayList<Hit> hitsCollection;
ArrayList<Hsp> hspsCollection;
List<Result> resultsCollection;
List<Hit> hitsCollection;
List<Hsp> hspsCollection;

try {
// select top level elements
Expand All @@ -102,7 +102,7 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
String dbFile = XMLHelper.selectSingleElement(blastDoc.getDocumentElement(),"BlastOutput_db").getTextContent();

logger.info("Query for hits in "+ targetFile);
ArrayList<Element> IterationsList = XMLHelper.selectElements(blastDoc.getDocumentElement(), "BlastOutput_iterations/Iteration[Iteration_hits]");
List<Element> IterationsList = XMLHelper.selectElements(blastDoc.getDocumentElement(), "BlastOutput_iterations/Iteration[Iteration_hits]");
logger.info(IterationsList.size() + " results");

resultsCollection = new ArrayList<>();
Expand All @@ -129,7 +129,7 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc


Element iterationHitsElement = XMLHelper.selectSingleElement(element, "Iteration_hits");
ArrayList<Element> hitList = XMLHelper.selectElements(iterationHitsElement, "Hit");
List<Element> hitList = XMLHelper.selectElements(iterationHitsElement, "Hit");

hitsCollection = new ArrayList<>();
for (Element hitElement : hitList) {
Expand All @@ -146,7 +146,7 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc
));

Element hithspsElement = XMLHelper.selectSingleElement(hitElement, "Hit_hsps");
ArrayList<Element> hspList = XMLHelper.selectElements(hithspsElement, "Hsp");
List<Element> hspList = XMLHelper.selectElements(hithspsElement, "Hsp");

hspsCollection = new ArrayList<>();
for (Element hspElement : hspList) {
Expand Down Expand Up @@ -195,7 +195,7 @@ public List<Result> createObjects(double maxEScore) throws IOException, ParseExc

@Override
public List<String> getFileExtensions(){
ArrayList<String> extensions = new ArrayList<>(1);
List<String> extensions = new ArrayList<>(1);
extensions.add("blastxml");
return extensions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,7 +38,7 @@
public class ChromosomeSequence extends DNASequence {

private int chromosomeNumber;
private LinkedHashMap<String, GeneSequence> geneSequenceHashMap = new LinkedHashMap<>();
private Map<String, GeneSequence> geneSequenceHashMap = new LinkedHashMap<>();

/**
* Empty constructor used by tools that need a proper Bean that allows the actual
Expand Down Expand Up @@ -106,7 +107,7 @@ public void setChromosomeNumber(int chromosomeNumber) {
* @return
*/

public LinkedHashMap<String, GeneSequence> getGeneSequences() {
public Map<String, GeneSequence> getGeneSequences() {
return geneSequenceHashMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.List;

/**
*
Expand All @@ -41,11 +43,11 @@ public class GeneSequence extends DNASequence {

private final static Logger logger = LoggerFactory.getLogger(GeneSequence.class);

private final LinkedHashMap<String, TranscriptSequence> transcriptSequenceHashMap = new LinkedHashMap<>();
private final LinkedHashMap<String, IntronSequence> intronSequenceHashMap = new LinkedHashMap<>();
private final LinkedHashMap<String, ExonSequence> exonSequenceHashMap = new LinkedHashMap<>();
private final ArrayList<IntronSequence> intronSequenceList = new ArrayList<>();
private final ArrayList<ExonSequence> exonSequenceList = new ArrayList<>();
private final Map<String, TranscriptSequence> transcriptSequenceHashMap = new LinkedHashMap<>();
private final Map<String, IntronSequence> intronSequenceHashMap = new LinkedHashMap<>();
private final Map<String, ExonSequence> exonSequenceHashMap = new LinkedHashMap<>();
private final List<IntronSequence> intronSequenceList = new ArrayList<>();
private final List<ExonSequence> 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;
Expand Down Expand Up @@ -179,7 +181,7 @@ public TranscriptSequence getTranscript(String accession) {
* Get the collection of transcription sequences assigned to this gene
* @return transcripts
*/
public LinkedHashMap<String, TranscriptSequence> getTranscripts() {
public Map<String, TranscriptSequence> getTranscripts() {
return transcriptSequenceHashMap;
}

Expand Down Expand Up @@ -294,15 +296,15 @@ 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<ExonSequence> getExonSequences() {
public List<ExonSequence> getExonSequences() {
return new ArrayList<>(exonSequenceList);
}

/**
* Get the introns as an ArrayList. Modifying this list will not modify the underlying collection
* @return introns
*/
public ArrayList<IntronSequence> getIntronSequences() {
public List<IntronSequence> getIntronSequences() {
return new ArrayList<>(intronSequenceList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -163,7 +164,7 @@ private DNASequence getRawParentSequence(String accessId) throws IOException {
= new FastaReader<>(is,
new PlainFastaHeaderParser<DNASequence, NucleotideCompound>(),
new DNASequenceCreator(AmbiguityDNACompoundSet.getDNACompoundSet()));
LinkedHashMap<String, DNASequence> seq = parentReader.process();
Map<String, DNASequence> seq = parentReader.process();

DNASequence parentSeq = null;
if (seq.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,8 +43,8 @@ public class TranscriptSequence extends DNASequence {

private final static Logger logger = LoggerFactory.getLogger(TranscriptSequence.class);

private final ArrayList<CDSSequence> cdsSequenceList = new ArrayList<>();
private final LinkedHashMap<String, CDSSequence> cdsSequenceHashMap = new LinkedHashMap<>();
private final List<CDSSequence> cdsSequenceList = new ArrayList<>();
private final Map<String, CDSSequence> cdsSequenceHashMap = new LinkedHashMap<>();
private StartCodonSequence startCodonSequence = null;
private StopCodonSequence stopCodonSequence = null;
private GeneSequence parentGeneSequence = null;
Expand Down Expand Up @@ -110,7 +112,7 @@ public CDSSequence removeCDS(String accession) {
* Get the CDS sequences that have been added to the TranscriptSequences
* @return
*/
public LinkedHashMap<String, CDSSequence> getCDSSequences() {
public Map<String, CDSSequence> getCDSSequences() {
return cdsSequenceHashMap;
}

Expand Down Expand Up @@ -152,8 +154,8 @@ public CDSSequence addCDS(AccessionID accession, int begin, int end, int phase)
*
* @return
*/
public ArrayList<ProteinSequence> getProteinCDSSequences() {
ArrayList<ProteinSequence> proteinSequenceList = new ArrayList<>();
public List<ProteinSequence> getProteinCDSSequences() {
List<ProteinSequence> proteinSequenceList = new ArrayList<>();
for (int i = 0; i < cdsSequenceList.size(); i++) {
CDSSequence cdsSequence = cdsSequenceList.get(i);
String codingSequence = cdsSequence.getCodingSequence();
Expand Down
Loading