Closed KaiLiCn closed 3 years ago
Hi,
Sorry for the delay of my answer. It seems that the factory fails to parse your file and then defaults to the standard modifications. May I know what unimod file you are referring to?
This part of the code is not really well written I am sorry, we are currently refactoring it, hopefully coming versions will be more intuitive. If you are missing modifications from our list you can add them via the GUI of SearchGUI or via the following command line. I am in process of testing and documenting this, don't hesitate to ask if you encounter issues.
Hope this helps,
Marc
Hi Marc,
At first I converted unimod.xml downloaded from UNIMOD to json, and then I added it into PTMFactory. But it didn't work. So, I found ptmFactory-4.12.1.json in .compomics and read it by PTMFactory, there was no more modifications as well.
Meanwhile, I tried to add modification singly by .addUserPTM, but I met same problem. However, after reading your PTMFactory codes and changing something, it worked! The codes changed as follow.
`/**
@param ptm the new modification to add */ public void addUserPTM(PTM ptm) {
String modName = ptm.getName();
ptmMap.put(modName, ptm);
if (!userMods.contains(modName)) {
userMods.add(modName);
} else {
userMods.set(userMods.indexOf(modName), modName);
}
usersModsSorted = false;
// add the neutral losses and reporter ions
if (!ptm.getNeutralLosses().isEmpty()) {
for (NeutralLoss neutralLoss : ptm.getNeutralLosses()) {
if (NeutralLoss.getNeutralLoss(neutralLoss.name) == null) {
NeutralLoss.addNeutralLoss(neutralLoss);
}
}
}
if (!ptm.getReporterIons().isEmpty()) {
for (ReporterIon reporterIon : ptm.getReporterIons()) {
if (ReporterIon.getReporterIon(reporterIon.getName()) == null) {
ReporterIon.addReporterIon(reporterIon);
}
}
}
instance = PTMFactory.this;// Essential for saving added ones
}`
It is essential to update instance. I wish it could help you.
Best regards!
Kai
Issue assumed resolved in more recent versions of utilities. If this is not the case, please let us know and we'll reopen the issue.
Hi:
When I tried to get all modifications, I found the number of that in PTMFactory is always 143 which means your default ones. However, the default file in folder .compomics was from unimod which has at least thousands of modifications.
` /**
@return the instance of the factory */ public static PTMFactory getInstance() { if (instance == null) { try { File savedFile = new File(SERIALIZATION_FILE_FOLDER, SERIALIZATION_FILE_NAME); instance = loadFromFile(savedFile); instance.checkUserModifications(); } catch (Exception e) {
}`
And then, I tested source codes and found it ran catch part each time which means default modifications returned only.
Do you know how to add all modifications from file into PTMFactory when PTMFactory.getInstance?
Kai