Skip to content
Open
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.23.1</version>
<version>2.25.4</version>
</dependency>

<dependency>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/compomics/software/ToolFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class ToolFactory {
* The command line argument for mgf files for SearchGUI.
*/
public static final String SEARCHGUI_SPECTRUM_FILE_OPTION = "-mgf";
public static final String searchGuiSpectrumFileOption = SEARCHGUI_SPECTRUM_FILE_OPTION;
/**
* The command line argument for FASTA file for SearchGUI.
*/
Expand All @@ -56,10 +57,12 @@ public class ToolFactory {
* The command line argument for a parameters file for SearchGUI.
*/
public static final String SEARCHGUI_PARAMETERS_FILE_OPTION = "-identification_parameters";
public static final String searchGuiParametersFileOption = SEARCHGUI_PARAMETERS_FILE_OPTION;
/**
* The command line argument for an output folder.
*/
public static final String OUTPUT_FOLDER_OPTION = "-output_folder";
public static final String outputFolderOption = OUTPUT_FOLDER_OPTION;
/**
* The command line argument for the species.
*/
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/com/compomics/util/Util.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.compomics.util;

import com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX;
import com.compomics.util.gui.file_handling.FileChooserUtil;
import java.awt.Color;
import java.awt.Component;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
Expand Down Expand Up @@ -695,4 +697,47 @@ public static String keyValueToString(
return sb.toString();

}

public static File getUserSelectedFile(
Component parent,
String fileEnding,
String fileFormatDescription,
String dialogTitle,
String lastSelectedFolder,
String suggestedFileName,
boolean openDialog
) {
return FileChooserUtil.getUserSelectedFile(
parent,
fileEnding,
fileFormatDescription,
dialogTitle,
lastSelectedFolder,
suggestedFileName,
openDialog
);
}

public static boolean deleteDir(File directory) {
if (directory == null || !directory.exists()) {
return true;
}
File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
deleteDir(file);
} else if (!file.delete()) {
return false;
}
}
}
return directory.delete();
}

public static String getFileName(File file) {
String name = file.getName();
int extensionIndex = name.lastIndexOf('.');
return extensionIndex > 0 ? name.substring(0, extensionIndex) : name;
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/compomics/util/db/object/ObjectsCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public class ObjectsCache {
*/
private final int keepObjectsThreshold = 10000;

/**
* Constructor.
*/
public ObjectsCache() {
}

/**
* Constructor.
*
Expand Down Expand Up @@ -466,6 +472,25 @@ public boolean isEmpty() {
return isEmpty;
}

/**
* Legacy compatibility method. Automated memory management is handled by
* the current cache implementation.
*
* @param automatedMemoryManagement ignored
*/
public void setAutomatedMemoryManagement(boolean automatedMemoryManagement) {
}

/**
* Legacy compatibility method. Delegates to the current memory share.
*
* @param memoryShare the memory share
* @param waitingHandler the waiting handler
*/
public void reduceMemoryConsumption(double memoryShare, WaitingHandler waitingHandler) {
setMemoryShare(memoryShare);
}

/**
* Clears the cache.
*/
Expand Down
43 changes: 41 additions & 2 deletions src/main/java/com/compomics/util/exceptions/ExceptionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,53 @@ public ExceptionHandler() {
public synchronized void catchException(Exception e) {

if (!ignoreExceptions && !exceptionCaught.contains(getExceptionType(e))) {

e.printStackTrace();
exceptionCaught.add(getExceptionType(e));

// @TODO: remove once the underlying Nimbus look and feel bug is fixed.
// On recent JDKs the Nimbus look and feel can throw a benign
// ClassCastException ("ColorUIResource cannot be cast to Boolean" in
// NimbusStyle.isOpaque) while building chart popup menus. It does not
// affect functionality, so it is logged above but not shown to the user.
if (isBenignLookAndFeelException(e)) {
return;
}

notifyUser(e);

}
}

/**
* Indicates whether the given exception is the known benign look and feel
* ClassCastException thrown while rendering (e.g. "ColorUIResource cannot be
* cast to Boolean" in NimbusStyle). Such exceptions do not affect
* functionality and should not be reported to the user.
*
* @param e the exception to inspect
*
* @return true if the exception is a benign look and feel rendering exception
*/
private static boolean isBenignLookAndFeelException(Exception e) {

if (!(e instanceof ClassCastException)) {
return false;
}

for (StackTraceElement element : e.getStackTrace()) {

String className = element.getClassName();

if (className.startsWith("javax.swing.plaf.nimbus.")
|| className.startsWith("javax.swing.plaf.synth.")) {
return true;
}
}

return false;
}

/**
* Notifies the user that an exception was caught.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.compomics.util.experiment.biology.aminoacids.sequence;

import com.compomics.util.experiment.biology.aminoacids.AminoAcid;
import com.compomics.util.experiment.identification.matches.ModificationMatch;
import com.compomics.util.experiment.personalization.ExperimentObject;
import com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters;
import com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters.MatchingType;
Expand Down Expand Up @@ -146,6 +147,14 @@ public HashMap<Integer, ArrayList<Character>> getAaTargeted() {
return residueTargeted;
}

public ArrayList<Integer> getModificationIndexes() {
return new ArrayList<>();
}

public ArrayList<ModificationMatch> getModificationsAt(int site) {
return new ArrayList<>();
}

/**
* Convenience constructor giving a list of targeted residues as input. For
* instance (S, T, Y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,48 @@ public ModificationMatch[] getVariableModifications() {

}

public ArrayList<Integer> getModificationIndexes() {
ArrayList<Integer> result = new ArrayList<>();
for (ModificationMatch modificationMatch : getVariableModifications()) {
if (!result.contains(modificationMatch.getSite())) {
result.add(modificationMatch.getSite());
}
}
return result;
}

public ArrayList<ModificationMatch> getModificationsAt(int site) {
ArrayList<ModificationMatch> result = new ArrayList<>();
for (ModificationMatch modificationMatch : getVariableModifications()) {
if (modificationMatch.getSite() == site) {
result.add(modificationMatch);
}
}
return result;
}

public static String getTaggedResidue(
char aminoAcid,
String modificationName,
ModificationParameters modificationParameters,
int modificationType,
boolean useHtmlColorCoding,
boolean useShortName
) {
String[] variableModifications = new String[3];
variableModifications[1] = modificationName;
return ModificationUtils.getTaggedModifiedSequence(
modificationParameters,
Character.toString(aminoAcid),
variableModifications,
null,
null,
new String[3],
useHtmlColorCoding,
useShortName
);
}

/**
* Returns the variable modifications indexed by site. Modifications are
* indexed by site as follows: N-term modifications are at index 0, C-term
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@
*/
public class Charge {

/**
* Legacy charge value field.
*/
public int value;

/**
* Empty default constructor.
*/
public Charge() {
}

/**
* Constructor with a charge value.
*
* @param value the charge value
*/
public Charge(int value) {
this.value = value;
}

/**
* Returns a string representing the charge. For example 2+.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
*/
public class Modification extends ExperimentObject {

public static final int MODAA = ModificationType.modaa.index;
public static final int MODN = ModificationType.modn_protein.index;
public static final int MODNAA = ModificationType.modnaa_protein.index;
public static final int MODC = ModificationType.modc_protein.index;
public static final int MODCAA = ModificationType.modcaa_protein.index;
public static final int MODNP = ModificationType.modn_peptide.index;
public static final int MODNPAA = ModificationType.modnaa_peptide.index;
public static final int MODCP = ModificationType.modc_peptide.index;
public static final int MODCPAA = ModificationType.modcaa_peptide.index;

/**
* The version UID for backward compatibility.
*/
Expand Down Expand Up @@ -171,6 +181,18 @@ public ModificationType getModificationType() {
return modificationType;
}

public int getType() {
return modificationType.index;
}

public boolean isNTerm() {
return modificationType.isNTerm();
}

public boolean isCTerm() {
return modificationType.isCTerm();
}

/**
* Getter for the modification name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ public boolean containsModification(String name) {
return modificationMap.containsKey(name);
}

public boolean containsPTM(String name) {
return containsModification(name);
}

/**
* Returns the names of the default modifications.
*
Expand Down Expand Up @@ -337,6 +341,10 @@ public ArrayList<String> getModifications() {
return new ArrayList<>(modificationMap.keySet());
}

public ArrayList<String> getPTMs() {
return getModifications();
}

/**
* Convenience method returning a boolean indicating whether a Modification
* is user defined or default.
Expand Down Expand Up @@ -407,6 +415,18 @@ public void setColor(String expectedModification, int color) {
userColors.put(expectedModification, color);
}

public void setColor(String expectedModification, Color color) {
setColor(expectedModification, color.getRGB());
}

public void addFixedModifications(
ModificationParameters modificationParameters,
com.compomics.util.experiment.identification.amino_acid_tags.Tag tag,
com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters sequenceMatchingParameters
) {
// Fixed modifications are resolved on demand in Utilities 5.
}

/**
* Returns a default color based on the modification name.
*
Expand Down
Loading