Skip to content

Commit

Permalink
Merge pull request #1086 from jlerbsc/master
Browse files Browse the repository at this point in the history
Fix sonar issue 2629 Logging arguments should not require evaluation
  • Loading branch information
josemduarte committed Mar 6, 2024
2 parents f94e577 + 1ac29b3 commit 81e0544
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static void createValidationFiles(URLConnection resourceUrlConnection, Fi
if(size == -1) {
logger.warn("could not find expected file size for resource {}.", resourceUrlConnection.getURL());
} else {
logger.debug("Content-Length: " + size);
logger.debug("Content-Length: {}", size);
File sizeFile = new File(localDestination.getParentFile(), localDestination.getName() + SIZE_EXT);
try (PrintStream sizePrintStream = new PrintStream(sizeFile)) {
sizePrintStream.print(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void clusterIt() {
dendrogram = new LinkedPair[numItems-1];


logger.debug("Initial matrix: \n"+matrixToString());
logger.debug("Initial matrix: \n{}", matrixToString());


for (int m=0;m<numItems-1;m++) {
Expand Down Expand Up @@ -309,11 +309,11 @@ public Map<Integer, Set<Integer>> getClusters(double cutoff) {
}
}

logger.debug("Within cutoff: "+dendrogram[i]);
logger.debug("Within cutoff: {}", dendrogram[i]);

} else {

logger.debug("Not within cutoff: "+dendrogram[i]);
logger.debug("Not within cutoff: {}", dendrogram[i]);

}
}
Expand Down Expand Up @@ -344,7 +344,7 @@ public Map<Integer, Set<Integer>> getClusters(double cutoff) {

}

logger.debug("Clusters: \n"+clustersToString(finalClusters));
logger.debug("Clusters: \n{}", clustersToString(finalClusters));

return finalClusters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ public static int getCDSLength(GeneChromosomePosition chromPos) {
*/
public static ChromPos getChromosomePosForCDScoordinate(int cdsNucleotidePosition, GeneChromosomePosition chromPos) {

logger.debug(" ? Checking chromosome position for CDS position " + cdsNucleotidePosition);
logger.debug(" ? Checking chromosome position for CDS position {}", cdsNucleotidePosition);

List<Integer> exonStarts = chromPos.getExonStarts();
List<Integer> exonEnds = chromPos.getExonEnds();

logger.debug(" Exons:" + exonStarts.size());
logger.debug(" Exons:{}", exonStarts.size());

int cdsStart = chromPos.getCdsStart();
int cdsEnd = chromPos.getCdsEnd();
Expand Down Expand Up @@ -378,7 +378,7 @@ public static ChromPos getChromPosReverse(int cdsPos, List<Integer> exonStarts,

if ( tmp > (end - start ) ) {
tmp = (end - start );
logger.debug("changing tmp to " + tmp);
logger.debug("changing tmp to {}", tmp);
}
logger.debug(" " + cdsPos + " " + codingLength + " | " + (cdsPos - codingLength) + " | " + (end -start) + " | " + tmp);
logger.debug(" Exon : " + format(start+1) + " - " + format(end) + " | " + format(end - start) + " | " + codingLength + " | " + (codingLength % 3));
Expand All @@ -397,7 +397,7 @@ public static ChromPos getChromPosReverse(int cdsPos, List<Integer> exonStarts,
logger.debug(" coding length: " + codingLength + "(phase:" + (codingLength % 3) + ") CDS POS trying to map:" + cdsPos);
}

logger.debug("length exons: " + lengthExons);
logger.debug("length exons: {}", lengthExons);
// could not map, or map over the full length??
return new ChromPos(-1,-1);

Expand Down Expand Up @@ -811,11 +811,11 @@ public static int getCDSPosForward(int chromPos, List<Integer> exonStarts, List<

// the genetic coordinate is not in a coding region
if ( (chromPos < (cdsStart+base) ) || ( chromPos > (cdsEnd+base) ) ) {
logger.debug("The "+format(chromPos)+" position is not in a coding region");
logger.debug("The {} position is not in a coding region", format(chromPos));
return -1;
}

logger.debug("looking for CDS position for " +format(chromPos));
logger.debug("looking for CDS position for {}", format(chromPos));

// map the genetic coordinates of coding region on a stretch of a reverse strand
List<Range<Integer>> cdsRegions = getCDSRegions(exonStarts, exonEnds, cdsStart, cdsEnd);
Expand Down Expand Up @@ -858,11 +858,11 @@ public static int getCDSPosReverse(int chromPos, List<Integer> exonStarts, List<

// the genetic coordinate is not in a coding region
if ( (chromPos < (cdsStart+base)) || ( chromPos > (cdsEnd+base) ) ) {
logger.debug("The "+format(chromPos)+" position is not in a coding region");
logger.debug("The {} position is not in a coding region", format(chromPos));
return -1;
}

logger.debug("looking for CDS position for " +format(chromPos));
logger.debug("looking for CDS position for {}", format(chromPos));

// map the genetic coordinate on a stretch of a reverse strand
List<Range<Integer>> cdsRegions = getCDSRegions(exonStarts, exonEnds, cdsStart, cdsEnd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,7 @@ public GroupType getPredominantGroupType(){
max = GroupType.HETATM;
}
}
logger.debug(
"Ratio of residues to total for chain with asym_id {} is below {}. Assuming it is a {} chain. "
+ "Counts: # aa residues: {}, # nuc residues: {}, # non-water het residues: {}, # waters: {}, "
+ "ratio aa/total: {}, ratio nuc/total: {}",
getId(), ratioResiduesToTotal, max, sizeAminos,
sizeNucleotides, sizeHetatomsWithoutWater, sizeWaters,
(double) sizeAminos / (double) fullSize,
(double) sizeNucleotides / (double) fullSize);
logger.debug("Ratio of residues to total for chain with asym_id {} is below {}. Assuming it is a {} chain. Counts: # aa residues: {}, # nuc residues: {}, # non-water het residues: {}, # waters: {}, ratio aa/total: {}, ratio nuc/total: {}{}{}{}{}", getId(), ratioResiduesToTotal, max, sizeAminos, sizeNucleotides, sizeHetatomsWithoutWater, sizeWaters, (double) sizeAminos, (double) fullSize, (double) sizeNucleotides, (double) fullSize);

return max;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,7 @@ public static Atom[] getAtomArray(Chain c, String[] atomNames) {
for (String atomName : atomNames) {
Atom a = g.getAtom(atomName);
if (a == null) {
logger.debug("Group " + g.getResidueNumber() + " ("
+ g.getPDBName()
+ ") does not have the required atom '" + atomName
+ "'");
logger.debug("Group {} ({}) does not have the required atom '{}'", g.getResidueNumber(), g.getPDBName(), atomName);
// this group does not have a required atom, skip it...
thisGroupAllAtoms = false;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ public void align(Atom[] ca1, Atom[] ca2, StrucAligParameters params)

// step 1 get all Diagonals of length X that are similar between both
// structures
logger.debug(" length atoms1:" + ca1.length);
logger.debug(" length atoms2:" + ca2.length);
logger.debug(" length atoms1:{}", ca1.length);
logger.debug(" length atoms2:{}", ca2.length);

logger.debug("step 1 - get fragments with similar intramolecular distances ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ public JointFragments[] frag_pairwise_compat(FragmentPair[] fraglst, int angleDi
List<JointFragments> fll = new ArrayList<JointFragments>();

double adiff = angleDiff * Math.PI / 180d;
logger.debug("addiff" + adiff);
logger.debug("addiff{}", adiff);
//distance between two unit vectors with angle adiff
double ddiff = Math.sqrt(2.0-2.0*Math.cos(adiff));
logger.debug("ddiff" + ddiff);
logger.debug("ddiff{}", ddiff);

// the fpairs in the flist have to be sorted with respect to their positions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public AFPChain align(Atom[] ca1, Atom[] ca2, Object parameters)
throw new StructureException("Empty alignment for sequences "+s1+" and "+s2);
}

logger.debug("Smith-Waterman alignment is: "+pair.toString(100));
logger.debug("Smith-Waterman alignment is: {}", pair.toString(100));

// convert to a 3D alignment...
afpChain = convert(ca1,ca2,pair, smithWaterman);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static List<Subunit> extractSubunits(Structure structure,
// Calculate the minimum length of a Subunit
int adjustedMinLen = calcAdjustedMinimumSequenceLength(subunits,
absMinLen, fraction, minLen);
logger.debug("Adjusted minimum sequence length: " + adjustedMinLen);
logger.debug("Adjusted minimum sequence length: {}", adjustedMinLen);

// Filter out short Subunits
for (int s = subunits.size() - 1; s >= 0; s--) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,13 @@ public String toString() {
public static StructureInterfaceList calculateInterfaces(Structure struc) {
CrystalBuilder builder = new CrystalBuilder(struc);
StructureInterfaceList interfaces = builder.getUniqueInterfaces();
logger.debug("Calculating ASA for "+interfaces.size()+" potential interfaces");
logger.debug("Calculating ASA for {} potential interfaces", interfaces.size());
interfaces.calcAsas(StructureInterfaceList.DEFAULT_ASA_SPHERE_POINTS, //fewer for performance
Runtime.getRuntime().availableProcessors(),
StructureInterfaceList.DEFAULT_MIN_COFACTOR_SIZE);
interfaces.removeInterfacesBelowArea();
interfaces.getClusters();
logger.debug("Found "+interfaces.size()+" interfaces");
logger.debug("Found {} interfaces", interfaces.size());
return interfaces;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Map<K,V> reloadFromFile() {

try{

logger.debug("Reloading from cache " + f.getAbsolutePath());
logger.debug("Reloading from cache {}", f.getAbsolutePath());

FileInputStream fis = new FileInputStream(f);
ObjectInputStream ois = new ObjectInputStream(fis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ private void calcRmsd(Point3d[] x, Point3d[] y) {
// translate to origin
xref = CalcPoint.clonePoint3dArray(x);
xtrans = CalcPoint.centroid(xref);
logger.debug("x centroid: " + xtrans);
logger.debug("x centroid: {}", xtrans);
xtrans.negate();
CalcPoint.translate(new Vector3d(xtrans), xref);

yref = CalcPoint.clonePoint3dArray(y);
ytrans = CalcPoint.centroid(yref);
logger.debug("y centroid: " + ytrans);
logger.debug("y centroid: {}", ytrans);
ytrans.negate();
CalcPoint.translate(new Vector3d(ytrans), yref);
innerProduct(yref, xref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private static TreeMap<String,EntityInfo> findEntitiesFromAlignment(List<List<Ch

logger.debug("Alignment for chain pair {},{}: identity: {}, gap coverage 1: {}, gap coverage 2: {}",
c1.getId(), c2.getId(), String.format("%4.2f",identity), String.format("%4.2f",gapCov1), String.format("%4.2f",gapCov2));
logger.debug("\n"+pair.toString(100));
logger.debug("\n{}", pair.toString(100));

if (identity > IDENTITY_THRESHOLD && gapCov1<GAP_COVERAGE_THRESHOLD && gapCov2<GAP_COVERAGE_THRESHOLD) {
if ( !chainIds2entities.containsKey(c1.getId()) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public boolean deleteStructure(PdbId pdbId) throws IOException{
// delete file
boolean success = existing.delete();
if(success) {
logger.debug("Deleting "+existing.getAbsolutePath());
logger.debug("Deleting {}", existing.getAbsolutePath());
}
deleted = deleted || success;

Expand All @@ -445,7 +445,7 @@ public boolean deleteStructure(PdbId pdbId) throws IOException{
if(parent != null) {
success = parent.delete();
if(success) {
logger.debug("Deleting "+parent.getAbsolutePath());
logger.debug("Deleting {}", parent.getAbsolutePath());
}
}

Expand Down
Loading

0 comments on commit 81e0544

Please sign in to comment.