Skip to content

Commit

Permalink
Fix sonar issue S2293 Replace the type specification in this construc…
Browse files Browse the repository at this point in the history
…tor call with the diamond operator ('<>')
  • Loading branch information
jlerbsc committed Apr 18, 2024
1 parent 266d835 commit b182121
Show file tree
Hide file tree
Showing 324 changed files with 1,102 additions and 1,102 deletions.
Expand Up @@ -95,8 +95,8 @@ public static void run(String[] args) throws Exception{
/*
* Parse input arguments
*/
List<Character> propertyList = new ArrayList<Character>();
List<Character> specificList = new ArrayList<Character>();
List<Character> propertyList = new ArrayList<>();
List<Character> specificList = new ArrayList<>();
String inputLocation = null;
String outputLocation = null;
String aminoAcidCompositionLocation = null;
Expand Down Expand Up @@ -179,14 +179,14 @@ private static LinkedHashMap<String, ProteinSequence> readInputFile(String input
}
LinkedHashMap<String, ProteinSequence> ret;
if ( inputLocation.toLowerCase().contains(".gb")) {
GenbankReader<ProteinSequence, AminoAcidCompound> genbankReader = new GenbankReader<ProteinSequence, AminoAcidCompound>(
GenbankReader<ProteinSequence, AminoAcidCompound> genbankReader = new GenbankReader<>(
inStream, new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(set));
ret = genbankReader.process();


} else {
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<>(
inStream, new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(set));
ret = fastaReader.process();
Expand Down Expand Up @@ -214,7 +214,7 @@ private static void printHeader(PrintStream output, List<Character> propertyList
* 9 Composition of the 20 standard amino acid
* 0 Composition of the specific amino acid
*/
List<String> sList = new ArrayList<String>();
List<String> sList = new ArrayList<>();
sList.add("SequenceName");
for(Character c:propertyList){
switch(c){
Expand Down Expand Up @@ -277,7 +277,7 @@ private static void compute(PrintStream output, String header, String sequence,
IPeptideProperties pp = new PeptidePropertiesImpl();

int specificCount = 0;
List<Double> dList = new ArrayList<Double>();
List<Double> dList = new ArrayList<>();
for(Character c:propertyList){
switch(c){
case '1':
Expand Down
Expand Up @@ -64,14 +64,14 @@ public class Constraints {
public static AminoAcidCompound Y = aaSet.getCompoundForString("Y");
public static AminoAcidCompound V = aaSet.getCompoundForString("V");

public static Map<AminoAcidCompound, Double> aa2ExtinctionCoefficient = new HashMap<AminoAcidCompound, Double>();
public static Map<AminoAcidCompound, Double> aa2MolecularWeight = new HashMap<AminoAcidCompound, Double>();
public static Map<AminoAcidCompound, Double> aa2Hydrophathicity = new HashMap<AminoAcidCompound, Double>();
public static Map<AminoAcidCompound, Double> aa2PKa = new HashMap<AminoAcidCompound, Double>();
public static Map<String, Double> diAA2Instability = new HashMap<String, Double>();
public static Map<AminoAcidCompound, Double> aa2ExtinctionCoefficient = new HashMap<>();
public static Map<AminoAcidCompound, Double> aa2MolecularWeight = new HashMap<>();
public static Map<AminoAcidCompound, Double> aa2Hydrophathicity = new HashMap<>();
public static Map<AminoAcidCompound, Double> aa2PKa = new HashMap<>();
public static Map<String, Double> diAA2Instability = new HashMap<>();

public static Map<AminoAcidCompound, Double> aa2NTerminalPka = new HashMap<AminoAcidCompound, Double>();
public static Map<AminoAcidCompound, Double> aa2CTerminalPka = new HashMap<AminoAcidCompound, Double>();
public static Map<AminoAcidCompound, Double> aa2NTerminalPka = new HashMap<>();
public static Map<AminoAcidCompound, Double> aa2CTerminalPka = new HashMap<>();

static{
initMolecularWeight();
Expand Down
Expand Up @@ -532,7 +532,7 @@ public static final Map<AminoAcidCompound, Double> getAAComposition(String seque
*/
public static final Map<String, Double> getAACompositionString(String sequence){
Map<AminoAcidCompound, Double> aa2Composition = getAAComposition(sequence);
Map<String, Double> aaString2Composition = new HashMap<String, Double>();
Map<String, Double> aaString2Composition = new HashMap<>();
aaString2Composition = aa2Composition.keySet().stream() .collect(Collectors.toMap(aaCompound -> aaCompound.getShortName(),aaCompound ->aa2Composition.get(aaCompound)));
return aaString2Composition;
}
Expand All @@ -550,7 +550,7 @@ public static final Map<String, Double> getAACompositionString(String sequence){
*/
public static final Map<Character, Double> getAACompositionChar(String sequence){
Map<AminoAcidCompound, Double> aa2Composition = getAAComposition(sequence);
Map<Character, Double> aaChar2Composition = new HashMap<Character, Double>();
Map<Character, Double> aaChar2Composition = new HashMap<>();
for(AminoAcidCompound aaCompound:aa2Composition.keySet()){
aaChar2Composition.put(aaCompound.getShortName().charAt(0), aa2Composition.get(aaCompound));
}
Expand Down
Expand Up @@ -210,7 +210,7 @@ private Map<AminoAcidCompound, Integer> getExtinctAACount(ProteinSequence sequen
}
}
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
Map<AminoAcidCompound, Integer> extinctAA2Count = new HashMap<AminoAcidCompound, Integer>();
Map<AminoAcidCompound, Integer> extinctAA2Count = new HashMap<>();
//Ignore Case is always true
extinctAA2Count.put(aaSet.getCompoundForString("W"), numW + smallW);
extinctAA2Count.put(aaSet.getCompoundForString("C"), (int) (numC + smallC));
Expand Down Expand Up @@ -532,7 +532,7 @@ private Map<AminoAcidCompound, Integer> getChargedAACount(ProteinSequence sequen
}
}
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
Map<AminoAcidCompound, Integer> chargedAA2Count = new HashMap<AminoAcidCompound, Integer>();
Map<AminoAcidCompound, Integer> chargedAA2Count = new HashMap<>();
chargedAA2Count.put(aaSet.getCompoundForString("K"), numK);
chargedAA2Count.put(aaSet.getCompoundForString("R"), numR);
chargedAA2Count.put(aaSet.getCompoundForString("H"), numH);
Expand All @@ -558,7 +558,7 @@ public double getEnrichment(ProteinSequence sequence, AminoAcidCompound aminoAci
@Override
public Map<AminoAcidCompound, Double> getAAComposition(ProteinSequence sequence) {
int validLength = 0;
Map<AminoAcidCompound, Double> aa2Composition = new HashMap<AminoAcidCompound, Double>();
Map<AminoAcidCompound, Double> aa2Composition = new HashMap<>();
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
for(AminoAcidCompound aa:aaSet.getAllCompounds()){
aa2Composition.put(aa, 0.0);
Expand Down
Expand Up @@ -106,7 +106,7 @@ public final static int getNumberOfInvalidChar(String sequence, Set<Character>
* a new sequence with all invalid characters being replaced by '-'.
*/
public final static String cleanSequence(String sequence, Set<Character> cSet){
Set<Character> invalidCharSet = new HashSet<Character>();
Set<Character> invalidCharSet = new HashSet<>();
StringBuilder cleanSeq = new StringBuilder();
if(cSet == null) cSet = PeptideProperties.standardAASet;
for(char c:sequence.toCharArray()){
Expand Down
Expand Up @@ -125,43 +125,43 @@ private Convertor getConvertor(ATTRIBUTE attribute) throws Exception{

@Override
public Map<GROUPING, Double> getComposition(ProteinSequence sequence, ATTRIBUTE attribute) throws Exception {
Map<GROUPING, Double> grouping2Composition = new HashMap<GROUPING, Double>();
Map<GROUPING, Double> grouping2Composition = new HashMap<>();
for(GROUPING group:GROUPING.values()) grouping2Composition.put(group, getComposition(sequence, attribute, group));
return grouping2Composition;
}

@Override
public Map<ATTRIBUTE, Map<GROUPING, Double>> getComposition(ProteinSequence sequence) throws Exception {
Map<ATTRIBUTE, Map<GROUPING, Double>> attribute2Grouping2Composition = new HashMap<ATTRIBUTE, Map<GROUPING, Double>>();
Map<ATTRIBUTE, Map<GROUPING, Double>> attribute2Grouping2Composition = new HashMap<>();
for(ATTRIBUTE attribute:ATTRIBUTE.values()) attribute2Grouping2Composition.put(attribute, getComposition(sequence, attribute));
return attribute2Grouping2Composition;
}

@Override
public Map<TRANSITION, Double> getTransition(ProteinSequence sequence, ATTRIBUTE attribute) throws Exception {
Map<TRANSITION, Double> transition2Double = new HashMap<TRANSITION, Double>();
Map<TRANSITION, Double> transition2Double = new HashMap<>();
for(TRANSITION transition:TRANSITION.values()) transition2Double.put(transition, getTransition(sequence, attribute, transition));
return transition2Double;
}

@Override
public Map<ATTRIBUTE, Map<TRANSITION, Double>> getTransition(ProteinSequence sequence) throws Exception {
Map<ATTRIBUTE, Map<TRANSITION, Double>> attribute2Transition2Double = new HashMap<ATTRIBUTE, Map<TRANSITION, Double>>();
Map<ATTRIBUTE, Map<TRANSITION, Double>> attribute2Transition2Double = new HashMap<>();
for(ATTRIBUTE attribute:ATTRIBUTE.values()) attribute2Transition2Double.put(attribute, getTransition(sequence, attribute));
return attribute2Transition2Double;
}

@Override
public Map<DISTRIBUTION, Double> getDistributionPosition(ProteinSequence sequence, ATTRIBUTE attribute, GROUPING group) throws Exception {
Map<DISTRIBUTION, Double> distribution2Double = new HashMap<DISTRIBUTION, Double>();
Map<DISTRIBUTION, Double> distribution2Double = new HashMap<>();
for(DISTRIBUTION distribution:DISTRIBUTION.values())
distribution2Double.put(distribution, getDistributionPosition(sequence, attribute, group, distribution));
return distribution2Double;
}

@Override
public Map<GROUPING, Map<DISTRIBUTION, Double>> getDistributionPosition(ProteinSequence sequence, ATTRIBUTE attribute) throws Exception {
Map<GROUPING, Map<DISTRIBUTION, Double>> grouping2Distribution2Double = new HashMap<GROUPING, Map<DISTRIBUTION, Double>>();
Map<GROUPING, Map<DISTRIBUTION, Double>> grouping2Distribution2Double = new HashMap<>();
for(GROUPING group:GROUPING.values())
grouping2Distribution2Double.put(group, getDistributionPosition(sequence, attribute, group));
return grouping2Distribution2Double;
Expand All @@ -170,7 +170,7 @@ public Map<GROUPING, Map<DISTRIBUTION, Double>> getDistributionPosition(ProteinS
@Override
public Map<ATTRIBUTE, Map<GROUPING, Map<DISTRIBUTION, Double>>> getDistributionPosition(ProteinSequence sequence) throws Exception {
Map<ATTRIBUTE, Map<GROUPING, Map<DISTRIBUTION, Double>>> attribute2Grouping2Distribution2Double =
new HashMap<ATTRIBUTE, Map<GROUPING, Map<DISTRIBUTION, Double>>>();
new HashMap<>();
for(ATTRIBUTE attribute:ATTRIBUTE.values())
attribute2Grouping2Distribution2Double.put(attribute, getDistributionPosition(sequence, attribute));
return attribute2Grouping2Distribution2Double;
Expand Down
Expand Up @@ -83,7 +83,7 @@ private void generatesAminoAcidCompoundSet(){
* Stores the mass of elements and isotopes
*/
public void computeMolecularWeight(ElementTable eTable){
this.aaSymbol2MolecularWeight = new HashMap<Character, Double>();
this.aaSymbol2MolecularWeight = new HashMap<>();
for(AminoAcidComposition a:aminoacid){
//Check to ensure that the symbol is of single character
if(a.getSymbol().length() != 1){
Expand Down
Expand Up @@ -39,9 +39,9 @@
*/
public class CaseFreeAminoAcidCompoundSet implements CompoundSet<AminoAcidCompound> {

private final Map<String, AminoAcidCompound> aminoAcidCompoundCache = new HashMap<String, AminoAcidCompound>();
private final Map<String, AminoAcidCompound> aminoAcidCompoundCache = new HashMap<>();
private final Map<AminoAcidCompound, Set<AminoAcidCompound>> equivalentsCache =
new HashMap<AminoAcidCompound, Set<AminoAcidCompound>>();
new HashMap<>();

public CaseFreeAminoAcidCompoundSet() {
aminoAcidCompoundCache.put("A", new AminoAcidCompound(null, "A", "Ala", "Alanine", 71.0788f));
Expand Down Expand Up @@ -83,7 +83,7 @@ public CaseFreeAminoAcidCompoundSet() {
//which then does the actual conversion to Pyl.
aminoAcidCompoundCache.put("O", new AminoAcidCompound(null, "O", "Pyl", "Pyrrolysine", 255.3172f));

Map<String, AminoAcidCompound> lowerCaseSet = new HashMap<String, AminoAcidCompound>();
Map<String, AminoAcidCompound> lowerCaseSet = new HashMap<>();
for(String s:this.aminoAcidCompoundCache.keySet()){
lowerCaseSet.put(s.toLowerCase(), this.aminoAcidCompoundCache.get(s));
}
Expand Down Expand Up @@ -144,7 +144,7 @@ public Set<AminoAcidCompound> getEquivalentCompounds(AminoAcidCompound compound)
addAmbiguousEquivalents("I", "L", "J");
// ambiguous gaps
AminoAcidCompound gap1, gap2, gap3;
Set<AminoAcidCompound> gaps = new HashSet<AminoAcidCompound>();
Set<AminoAcidCompound> gaps = new HashSet<>();
gaps.add(gap1 = aminoAcidCompoundCache.get("-"));
gaps.add(gap2 = aminoAcidCompoundCache.get("."));
gaps.add(gap3 = aminoAcidCompoundCache.get("_"));
Expand All @@ -162,18 +162,18 @@ private void addAmbiguousEquivalents(String one, String two, String either) {
Set<AminoAcidCompound> equivalents;
AminoAcidCompound cOne, cTwo, cEither;

equivalents = new HashSet<AminoAcidCompound>();
equivalents = new HashSet<>();
equivalents.add(cOne = aminoAcidCompoundCache.get(one));
equivalents.add(cTwo = aminoAcidCompoundCache.get(two));
equivalents.add(cEither = aminoAcidCompoundCache.get(either));
equivalentsCache.put(cEither, equivalents);

equivalents = new HashSet<AminoAcidCompound>();
equivalents = new HashSet<>();
equivalents.add(cOne);
equivalents.add(cEither);
equivalentsCache.put(cOne, equivalents);

equivalents = new HashSet<AminoAcidCompound>();
equivalents = new HashSet<>();
equivalents.add(cTwo);
equivalents.add(cEither);
equivalentsCache.put(cTwo, equivalents);
Expand All @@ -186,7 +186,7 @@ public boolean hasCompound(AminoAcidCompound compound) {

@Override
public List<AminoAcidCompound> getAllCompounds() {
return new ArrayList<AminoAcidCompound>(aminoAcidCompoundCache.values());
return new ArrayList<>(aminoAcidCompoundCache.values());
}


Expand Down
Expand Up @@ -120,7 +120,7 @@ public List<Isotope> getIsotopes() {

public void setIsotopes(List<Isotope> isotopes) {
this.isotope = isotopes;
this.name2Isotope = new HashMap<String, Isotope>();
this.name2Isotope = new HashMap<>();
if(isotopes != null){
for(Isotope i:isotopes){
name2Isotope.put(i.getName(), i);
Expand Down
Expand Up @@ -58,8 +58,8 @@ public void setElement(List<Element> eList){
* Populate the Maps for quick retrieval
*/
public void populateMaps(){
this.elementName2Element = new HashMap<String, Element>();
this.isotopeName2Isotope = new HashMap<String, Isotope>();
this.elementName2Element = new HashMap<>();
this.isotopeName2Isotope = new HashMap<>();
if(this.element != null){
for(Element e:this.element){
this.elementName2Element.put(e.getName(), e);
Expand Down
Expand Up @@ -28,7 +28,7 @@

public class ModifiedAminoAcidCompoundSet implements CompoundSet<AminoAcidCompound> {

private final Map<String, AminoAcidCompound> aminoAcidCompoundCache = new HashMap<String, AminoAcidCompound>();
private final Map<String, AminoAcidCompound> aminoAcidCompoundCache = new HashMap<>();

public ModifiedAminoAcidCompoundSet(List<AminoAcidComposition> aaList, Map<Character, Double> aaSymbol2MolecularWeight) {
this.aminoAcidCompoundCache.put("-", new AminoAcidCompound(null, "-", "", "", 0.0f));
Expand Down Expand Up @@ -84,7 +84,7 @@ public boolean hasCompound(AminoAcidCompound compound) {

@Override
public List<AminoAcidCompound> getAllCompounds() {
return new ArrayList<AminoAcidCompound>(aminoAcidCompoundCache.values());
return new ArrayList<>(aminoAcidCompoundCache.values());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion biojava-alignment/src/main/java/demo/CookbookMSA.java
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] args) throws Exception {
}

private static void multipleSequenceAlignment(String[] ids) throws Exception {
List<ProteinSequence> lst = new ArrayList<ProteinSequence>();
List<ProteinSequence> lst = new ArrayList<>();
for (String id : ids) {
lst.add(getSequenceForId(id));
}
Expand Down
4 changes: 2 additions & 2 deletions biojava-alignment/src/main/java/demo/DemoDistanceTree.java
Expand Up @@ -58,7 +58,7 @@ public static void main(String[] args) throws Exception {
.getResourceAsStream("/PF00104_small.fasta");

FastaReader<ProteinSequence, AminoAcidCompound> fastaReader =
new FastaReader<ProteinSequence, AminoAcidCompound>(
new FastaReader<>(
inStream,
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet
Expand All @@ -70,7 +70,7 @@ public static void main(String[] args) throws Exception {
inStream.close();

MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound> msa =
new MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound>();
new MultipleSequenceAlignment<>();

for (ProteinSequence proteinSequence : proteinSequences.values()) {
msa.addAlignedSequence(proteinSequence);
Expand Down

0 comments on commit b182121

Please sign in to comment.