diff --git a/nbactions.xml b/nbactions.xml index 291de58..1078daa 100644 --- a/nbactions.xml +++ b/nbactions.xml @@ -10,7 +10,7 @@ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - -Xmx3g -XX:+HeapDumpOnOutOfMemoryError -classpath %classpath org.rappsilber.fdr.CommandLine + -classpath %classpath org.rappsilber.fdr.CommandLine --pepfdr=5.0 --boost=link --csvOutDir=/home/lfischer/temp/test --csvBaseName=test_XiVersion1.7.754.RC1_2 --xiconfig=/home/lfischer/temp/test/test_XiVersion1.7.754.RC1.csv.config --fasta=/Users/salman/xi_data/xi/sequenceDB/pool8_BSCL-17_46_41-12_Sep_2019/DATABASE.fasta /home/lfischer/temp/test/test_XiVersion1.7.754.RC1.csv --gui java /home/lfischer @@ -25,7 +25,7 @@ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -Xmx3g -XX:+HeapDumpOnOutOfMemoryError -classpath %classpath org.rappsilber.fdr.CommandLine + -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.rappsilber.fdr.CommandLine --pepfdr=5.0 --boost=link --csvOutDir=/home/lfischer/temp/test --csvBaseName=test_XiVersion1.7.754.RC1_2 --xiconfig=/home/lfischer/temp/test/test_XiVersion1.7.754.RC1.csv.config --fasta=/Users/salman/xi_data/xi/sequenceDB/pool8_BSCL-17_46_41-12_Sep_2019/DATABASE.fasta /home/lfischer/temp/test/test_XiVersion1.7.754.RC1.csv --gui java true /home/lfischer @@ -41,7 +41,7 @@ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - -Xmx3g -XX:+HeapDumpOnOutOfMemoryError -classpath %classpath org.rappsilber.fdr.CommandLine + -classpath %classpath org.rappsilber.fdr.CommandLine --pepfdr=5.0 --boost=link --csvOutDir=/home/lfischer/temp/test --csvBaseName=test_XiVersion1.7.754.RC1_2 --xiconfig=/home/lfischer/temp/test/test_XiVersion1.7.754.RC1.csv.config --fasta=/Users/salman/xi_data/xi/sequenceDB/pool8_BSCL-17_46_41-12_Sep_2019/DATABASE.fasta /home/lfischer/temp/test/test_XiVersion1.7.754.RC1.csv --gui java /home/lfischer diff --git a/pom.xml b/pom.xml index 58906dd..5bca27a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.rappsilberlab xiFDR - 1.3.36 + 1.3.37 jar @@ -35,11 +35,6 @@ RUtils 1.0-SNAPSHOT - - rappsilber - XiSearch - 1.6.749 - org.rappsilber XLMOD @@ -103,6 +98,11 @@ CSV 1.0-SNAPSHOT + + rappsilber + XiSearch + 1.7.754.dev + @@ -145,5 +145,5 @@ Application for FDR estimation cross-linking massspectrometry data - xiFDR-1.3.36 + xiFDR-1.3.37 diff --git a/src/main/java/org/rappsilber/fdr/CSVinFDR.java b/src/main/java/org/rappsilber/fdr/CSVinFDR.java index ab1bc4a..ddd9b95 100644 --- a/src/main/java/org/rappsilber/fdr/CSVinFDR.java +++ b/src/main/java/org/rappsilber/fdr/CSVinFDR.java @@ -86,6 +86,8 @@ public class CSVinFDR extends OfflineFDR { {"crosslinker mass","cross linker mass","crossLinkerModMass","cross linker mod mass","crosslinkerModMass"}, {"peptide coverage1", "peptide1 unique matched non lossy coverage", "unique_peak_primary_coverage_p1"}, {"peptide coverage2", "peptide2 unique matched non lossy coverage", "unique_peak_primary_coverage_p2"}, + {"peptide1 fragments", "peptide1 unique matched conservative", "conservative_fragsites_p1"}, + {"peptide2 fragments", "peptide2 unique matched conservative", "conservative_fragsites_p2"}, {"minimum peptide coverage", "min coverage pp"}, {"delta", "delta score", "dscore"}, }; @@ -102,11 +104,6 @@ public CSVinFDR(int[] peptideLengthGroups) { @Override protected ArrayList getPSMHeader() { ArrayList ret = super.getPSMHeader(); -// String header = "PSMID" + seperator + "run" + seperator + "scan" -// + seperator + "exp charge" + seperator + "exp m/z" + seperator + "exp mass" + seperator + "exp fractionalmass" -// + seperator + "match charge" + seperator + "match mass" + seperator + "match fractionalmass" -// -// + seperator + "Protein1" + seperator + "Description1" + seperator + "Decoy1" + seperator + "Protein2" + seperator + "Description2" + seperator + "Decoy2" + seperator + "Peptide1" + seperator + "Peptide2" + seperator + "PeptidePosition1" + seperator + "PeptidePosition2" + seperator + "PeptideLength1" + seperator + "PeptideLength2" + seperator + "fromSite" + seperator + "ToSite" + seperator + "Charge" + seperator + "Score" + seperator + "isDecoy" + seperator + "isTT" + seperator + "isTD" + seperator + "isDD" + seperator + "fdrGroup" + seperator + "fdr" + seperator + "" + seperator + "PeptidePairFDR" + seperator + "Protein1FDR" + seperator + "Protein2FDR" + seperator + "LinkFDR" + seperator + "PPIFDR" + seperator + seperator + "peptide pair id" + seperator + "link id" + seperator + "ppi id"; ret.add(5, "exp charge"); ret.add(6, "exp m/z"); ret.add(7, "exp mass"); @@ -126,7 +123,6 @@ protected ArrayList getPSMOutputLine(PSM pp) { double mass = (mz-1.00727646677)*charge; double fraction = mass-Math.floor(mass); double calcfraction = pp.getCalcMass()-Math.floor(pp.getCalcMass()); - ret.add(5,""+ charge); ret.add(6, d2s(mz)); @@ -135,7 +131,6 @@ protected ArrayList getPSMOutputLine(PSM pp) { ret.add(9,i2s(pp.getCharge())); ret.add(10, d2s(pp.getCalcMass())); ret.add(11, d2s(calcfraction)); - return ret; } diff --git a/src/main/java/org/rappsilber/fdr/CommandLine.java b/src/main/java/org/rappsilber/fdr/CommandLine.java index b7a31c2..5f94848 100644 --- a/src/main/java/org/rappsilber/fdr/CommandLine.java +++ b/src/main/java/org/rappsilber/fdr/CommandLine.java @@ -33,7 +33,7 @@ public static void main(String args[]) throws SQLException, FileNotFoundExceptio boolean db = false; for (String a : args) { gui = false; - if (a.startsWith("--xiconfig=")) { + if (a.startsWith("--xiconfig=") || a.contentEquals("--gui")) { xicsv=true; } else if (a.startsWith("--dbids=")) { db = true; diff --git a/src/main/java/org/rappsilber/fdr/FDRSettings.java b/src/main/java/org/rappsilber/fdr/FDRSettings.java index 7ff4fbc..11a438f 100644 --- a/src/main/java/org/rappsilber/fdr/FDRSettings.java +++ b/src/main/java/org/rappsilber/fdr/FDRSettings.java @@ -165,6 +165,8 @@ public interface FDRSettings { public void ppiLocalFDR(Boolean local); public boolean combineScoreAndDelta(); public void combineScoreAndDelta(boolean c); + public boolean ignoreValidityChecks(); + public void ignoreValidityChecks(boolean ignore); // public double getSubScoreCutOff(); // public void setSubScoreCutOff(double localfdr); diff --git a/src/main/java/org/rappsilber/fdr/FDRSettingsImpl.java b/src/main/java/org/rappsilber/fdr/FDRSettingsImpl.java index 521e70d..1f73afe 100644 --- a/src/main/java/org/rappsilber/fdr/FDRSettingsImpl.java +++ b/src/main/java/org/rappsilber/fdr/FDRSettingsImpl.java @@ -61,6 +61,7 @@ public class FDRSettingsImpl implements FDRSettings { private boolean combineScoreAndDelta; private int minFragments; private boolean boostMinFragments = false; + private boolean ignoreValidityChecks; @Override public void addCalcListener(ActionListener al) { @@ -318,6 +319,7 @@ public static void transferSettings(FDRSettings from, FDRSettings to) { to.boostPepCoverage(from.boostPepCoverage()); to.boostDeltaScore(from.boostDeltaScore()); to.combineScoreAndDelta(from.combineScoreAndDelta()); + to.ignoreValidityChecks(from.ignoreValidityChecks()); } public boolean combineScoreAndDelta() { @@ -516,6 +518,16 @@ public int getMinPeptideFragmentsFilter() { public void setMinPeptideFragmentsFilter(int frags) { this.minFragments = frags; } + + @Override + public boolean ignoreValidityChecks() { + return this.ignoreValidityChecks; + } + + @Override + public void ignoreValidityChecks(boolean ignore) { + this.ignoreValidityChecks = ignore; + } } diff --git a/src/main/java/org/rappsilber/fdr/OfflineFDR.java b/src/main/java/org/rappsilber/fdr/OfflineFDR.java index b9f4325..15b55d2 100644 --- a/src/main/java/org/rappsilber/fdr/OfflineFDR.java +++ b/src/main/java/org/rappsilber/fdr/OfflineFDR.java @@ -52,6 +52,7 @@ import org.rappsilber.fdr.entities.AbstractFDRElement; import org.rappsilber.fdr.entities.FDRSelfAdd; import org.rappsilber.fdr.filter.DeltaScorePercentFilter; +import org.rappsilber.fdr.gui.FDRGUI; import org.rappsilber.fdr.utils.HashedArrayList; import org.rappsilber.fdr.utils.MaximisingStatus; import org.rappsilber.fdr.utils.MaximizeLevelInfo; @@ -1025,8 +1026,9 @@ public void calculatePSMFDR(boolean setElementFDR, boolean ignoreGroups, FDRResu result.maximumProteinAmbiguity = m_maximumProteinAmbiguity; result.maximumLinkAmbiguity = m_maximumLinkAmbiguity; - fdr(settings.getPSMFDR(), settings.getReportFactor(), inputPSM, GroupedFDRs, targetPepDBSize, decoyPepDBSize, 1, ignoreGroups, setElementFDR, settings.isPSMDirectional(), settings.isGroupByPSMCount(), settings.getMinTD()); - + fdr(settings.getPSMFDR(), settings, inputPSM, GroupedFDRs, targetPepDBSize, decoyPepDBSize, 1, ignoreGroups, setElementFDR, settings.psmLocalFDR(), settings.isGroupByPSMCount()); + + if (groupByHasInternal) { HashSet internal = new HashSet<>(); @@ -1046,10 +1048,16 @@ public void calculatePSMFDR(boolean setElementFDR, boolean ignoreGroups, FDRResu pp.setFDRGroup(pp.getFDRGroup() + " int_support"); } } - fdr(settings.getPSMFDR(), settings.getReportFactor(), inputPSM, GroupedFDRs, targetPepDBSize, decoyPepDBSize, 1, ignoreGroups, setElementFDR, settings.psmLocalFDR(), settings.isGroupByPSMCount(), settings.getMinTD()); + fdr(settings.getPSMFDR(), settings, inputPSM, GroupedFDRs, targetPepDBSize, decoyPepDBSize, 1, ignoreGroups, setElementFDR, settings.psmLocalFDR(), settings.isGroupByPSMCount()); GroupedFDRs = GroupedFDRsS; } + for (SubGroupFdrInfo rl : GroupedFDRs.getGroups()) { + if (rl.didntPassCheck) { + result.excludedGroups.add("PSM -> " + rl.fdrGroup); + } + } + result.psmFDR = GroupedFDRs; // return GroupedFDRs; @@ -1170,7 +1178,13 @@ public void calculatePeptidePairFDR(boolean setElementFDR, FDRResult result, FDR } } - fdr(settings.getPeptidePairFDR(), settings.getReportFactor(), psmPeps, GroupedFDRs, targetPepDBSize, decoyPepDBSize, 1, ignoreGroups, setElementFDR, settings.peppairLocalFDR(), settings.isGroupByPSMCount(), settings.getMinTD()); + fdr(settings.getPeptidePairFDR(), settings, psmPeps, GroupedFDRs, targetPepDBSize, decoyPepDBSize, 1, ignoreGroups, setElementFDR, settings.peppairLocalFDR(), settings.isGroupByPSMCount()); + + for (SubGroupFdrInfo rl : GroupedFDRs.getGroups()) { + if (rl.didntPassCheck) { + result.excludedGroups.add("PeptidePair -> " + rl.fdrGroup); + } + } result.peptidePairFDR = GroupedFDRs; } @@ -1246,7 +1260,13 @@ public void calculateProteinGroupFDR(boolean ignoreGroups, boolean setElementFDR filterListByPeptideSuport(pepProteinGroups, settings.getMinProteinPepCount()); } //Logger.getLogger(this.getClass().getName()).log(Level.INFO, "ProteinGroup fdr " + pepProteinGroups.size() + " Groups as Input."); - fdr(settings.getProteinGroupFDR(), settings.getReportFactor(), pepProteinGroups, GroupedFDRs, targetProtDBSize, decoyProtDBSize, settings.getMinProteinPepCount(), ignoreGroups, setElementFDR, settings.protLocalFDR(), false, settings.getMinTD()); + fdr(settings.getProteinGroupFDR(), settings, pepProteinGroups, GroupedFDRs, targetProtDBSize, decoyProtDBSize, settings.getMinProteinPepCount(), ignoreGroups, setElementFDR, settings.protLocalFDR(), false); + + for (SubGroupFdrInfo rl : GroupedFDRs.getGroups()) { + if (rl.didntPassCheck) { + result.excludedGroups.add("ProteinGroup -> " + rl.fdrGroup); + } + } result.proteinGroupFDR = GroupedFDRs; // fdrProteinGroups = fdr(fdr, safetyFactor, pepProteinGroups, nextFdrProteinGroup, protFDRGroupsInput, countFdrProteinGroup, tCountMod, dCountMod, minPepCount, ignoreGroups, setElementFDR); @@ -1321,7 +1341,7 @@ public void calculateLinkFDR(boolean ignoreGroups, boolean setElementFDR, FDRSet } } - fdr(settings.getProteinGroupLinkFDR(), settings.getReportFactor(), pepLinks, GroupedFDRs, targetLinkDBSize, decoyLinkDBSize, settings.getMinLinkPepCount(), ignoreGroups, setElementFDR, settings.linkLocalFDR(), settings.isGroupByPSMCount(), settings.getMinTD()); + fdr(settings.getProteinGroupLinkFDR(), settings, pepLinks, GroupedFDRs, targetLinkDBSize, decoyLinkDBSize, settings.getMinLinkPepCount(), ignoreGroups, setElementFDR, settings.linkLocalFDR(), settings.isGroupByPSMCount()); if (groupLinksByHasInternal) { HashSet internal = new HashSet<>(); @@ -1343,10 +1363,16 @@ public void calculateLinkFDR(boolean ignoreGroups, boolean setElementFDR, FDRSet } FDRResultLevel GroupedFDRs2 = new FDRResultLevel(); GroupedFDRs2.isDirectional = settings.isLinkDirectional(); - fdr(settings.getProteinGroupLinkFDR(), settings.getReportFactor(), pepLinks, GroupedFDRs2, targetLinkDBSize, decoyLinkDBSize, settings.getMinLinkPepCount(), ignoreGroups, setElementFDR, settings.linkLocalFDR(), settings.isGroupByPSMCount(), settings.getMinTD()); + fdr(settings.getProteinGroupLinkFDR(), settings, pepLinks, GroupedFDRs2, targetLinkDBSize, decoyLinkDBSize, settings.getMinLinkPepCount(), ignoreGroups, setElementFDR, settings.linkLocalFDR(), settings.isGroupByPSMCount()); GroupedFDRs = GroupedFDRs2; } + for (SubGroupFdrInfo rl : GroupedFDRs.getGroups()) { + if (rl.didntPassCheck) { + result.excludedGroups.add("ResiduePair -> " + rl.fdrGroup); + } + } + result.proteinGroupLinkFDR = GroupedFDRs; // fdrProtainGroupLinks = fdr(fdr, safetyFactor, pepLinks, nextFdrLink, linkFDRGroupsInput, countFdrLink, targetPepDBSize, decoyPepDBSize, minPepCount, ignoreGroups, setElementFDR); @@ -1430,7 +1456,13 @@ public void calculateProteinGroupPairFDR(boolean ignoreGroups, boolean setElemen } } - fdr(settings.getProteinGroupPairFDR(), settings.getReportFactor(), linkPPIs, GroupedFDRs, targetProtDBSize, decoyProtDBSize, minPepCount, ignoreGroups, setElementFDR, settings.ppiLocalFDR(), false, settings.getMinTD()); + fdr(settings.getProteinGroupPairFDR(), settings, linkPPIs, GroupedFDRs, targetProtDBSize, decoyProtDBSize, minPepCount, ignoreGroups, setElementFDR, settings.ppiLocalFDR(), false); + + for (SubGroupFdrInfo rl : GroupedFDRs.getGroups()) { + if (rl.didntPassCheck) { + result.excludedGroups.add("ProteinGroupPair -> " + rl.fdrGroup); + } + } result.proteinGroupPairFDR = GroupedFDRs; } @@ -1555,6 +1587,7 @@ public FDRResult calculateFDR(FDRSettings settings, boolean setElementFDR) { boolean ignoreGroups = this.ignoreGroupsSetting; result.reportFactor = settings.getReportFactor(); reset(); + result.excludedGroups =new ArrayList<>(); Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Input PSM :" + getAllPSMs().size() + "\n calculation psm-fdr"); calculatePSMFDR(setElementFDR, ignoreGroups, result, settings); @@ -1586,6 +1619,10 @@ public FDRResult calculateFDR(FDRSettings settings, boolean setElementFDR) { Logger.getLogger(this.getClass().getName()).log(Level.INFO, "fdr psms :" + result.psmFDR.getResultCount() + "\n filtering ProteinGroups by peptide pairs"); filterFDRProteinGroupsByFDRPeptidePairs(result); Logger.getLogger(this.getClass().getName()).log(Level.INFO, "fdr protein groups :" + result.proteinGroupFDR.getResultCount()); + + if (!result.excludedGroups.isEmpty()) { + Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Some FDR groups where ignored as being unreliable: "+ MyArrayUtils.toString(result.excludedGroups, "; ")); + } return result; @@ -2503,11 +2540,13 @@ public > boolean checkValid(SubGroupFdrInfo i * it group has at the given score? - is used to speed up the maximation (by * not setting these) */ - private > void fdr(double fdr, double safetyfactor, Collection fdrInput, FDRResultLevel groupInfo, double tCount, double dCount, int minPepCount, boolean ignoreGroups, boolean setElementFDR, Boolean localFDR, boolean groupByProteinPair, int minTDChance) { + private > void fdr(double fdr, FDRSettings settings, Collection fdrInput, FDRResultLevel groupInfo, double tCount, double dCount, int minPepCount, boolean ignoreGroups, boolean setElementFDR, Boolean localFDR, boolean groupByProteinPair) { HashMap> groupedList = new HashMap>(4); HashMap gTT = new HashMap(8); HashMap gTD = new HashMap(8); HashMap gDD = new HashMap(8); + double safetyfactor = settings.getReportFactor(); + int minTDChance = settings.getMinTD(); int resultcount = 0; // HashedArrayList ret = new HashedArrayList(c.size()); @@ -2672,10 +2711,10 @@ private > void fdr(double fdr, double safetyfact info.targteFDR = fdr; info.saftyfactor = safetyfactor; info.fdrGroup = fdrgroup; + subFDR(group, groupResult, setElementFDR, info); if (localFDR == null || localFDR) { - subFDRLocal(group, groupResult, info); + subFDRLocal(group, info); } - subFDR(group, groupResult, setElementFDR, info); if (localFDR != null && localFDR) { ArrayList filtered = new ArrayList<>(); for (T e : groupResult) { @@ -2695,7 +2734,7 @@ private > void fdr(double fdr, double safetyfact } // if (info.resultTT*fdr{1}({2})", new Object[]{group.get(0).getClass(), fdrgroup, group.get(0).getFDRGroup()}); //between if (fdrgroup.toLowerCase().contains("between")) { @@ -2751,7 +2790,7 @@ private > void fdr(double fdr, double safetyfact collectedToSmall.fdrGroup = "CollectedSmallResults [" + RArrayUtils.toString(collectedToSmallNames, ",") + "]"; subFDR(tooSmallGroup, groupResult, setElementFDR, collectedToSmall); if (localFDR == null || localFDR) { - subFDRLocal(tooSmallGroup, groupResult, collectedToSmall); + subFDRLocal(tooSmallGroup, collectedToSmall); if (localFDR != null) { ArrayList filtered = new ArrayList<>(); for (T e : groupResult) { @@ -2770,7 +2809,7 @@ private > void fdr(double fdr, double safetyfact groupResult = filtered; } } - if (checkValid(collectedToSmall, groupResult, 0, minTDChance)) { + if (settings.ignoreValidityChecks() || checkValid(collectedToSmall, groupResult, 0, minTDChance)) { groupInfo.addGroup(collectedToSmall.fdrGroup, collectedToSmall); // group, fdr, safetyfactor, groupResult, tCount, dCount,setElementFDR); // nextFDR.put(fdrgroup, prevFDR); @@ -2790,7 +2829,7 @@ private > void fdr(double fdr, double safetyfact collectedToSmallWithin.fdrGroup = "CollectedSmallResultsWithin [" + RArrayUtils.toString(collectedToSmallWithinNames, ",") + "]"; subFDR(tooSmallGroupWithin, groupResultwithin, setElementFDR, collectedToSmallWithin); if (localFDR == null || localFDR) { - subFDRLocal(tooSmallGroupWithin, groupResultwithin, collectedToSmallWithin); + subFDRLocal(tooSmallGroupWithin, collectedToSmallWithin); if (localFDR != null) { ArrayList filtered = new ArrayList<>(); for (T e : groupResultwithin) { @@ -2809,7 +2848,7 @@ private > void fdr(double fdr, double safetyfact groupResultwithin = filtered; } } - if (checkValid(collectedToSmallWithin, groupResultwithin, 0, minTDChance)) { + if (settings.ignoreValidityChecks() || checkValid(collectedToSmallWithin, groupResultwithin, 0, minTDChance)) { groupInfo.addGroup(collectedToSmallWithin.fdrGroup, collectedToSmallWithin); // group, fdr, safetyfactor, groupResult, tCount, dCount,setElementFDR); // nextFDR.put(fdrgroup, prevFDR); @@ -2840,7 +2879,7 @@ private > void fdr(double fdr, double safetyfact ArrayList all = new ArrayList(fdrInput); subFDR(all, allResult, setElementFDR, info); if (localFDR == null || localFDR) { - subFDRLocal(all, allResult, info); + subFDRLocal(all, info); if (localFDR != null) { ArrayList filtered = new ArrayList<>(); for (T e : allResult) { @@ -3220,7 +3259,7 @@ public int compare(T o1, T o2) { // we steped below the target fdr (efdr<= fdr) if (efdr <= fdr) { //did we just pas an fdr-step - if ((efdr < prevFDR || prevFDR == 0.0 || prevFDR == Double.POSITIVE_INFINITY) || fdr == Double.POSITIVE_INFINITY) { + if ((efdr < prevFDR || prevFDR <= 0.0 || prevFDR == Double.POSITIVE_INFINITY) || fdr == Double.POSITIVE_INFINITY) { // does it fullfill the saftyfactor if ((efdr_p / fdr < info.saftyfactor || info.saftyfactor > 1000 || info.saftyfactor == 0) || fdr == Double.POSITIVE_INFINITY) { //if ((efdr_p / fdr < info.saftyfactor && efdr_n >= 0) || fdr == Double.POSITIVE_INFINITY) { @@ -3381,10 +3420,7 @@ public int compare(T o1, T o2) { * @param setElementFDR * @return */ - protected > void subFDRLocal(ArrayList group, ArrayList results, SubGroupFdrInfo info) { - HashedArrayList ret = new HashedArrayList(); - info.results = ret; - info.filteredResult = ret; + protected > void subFDRLocal(ArrayList group, SubGroupFdrInfo info) { int TT = info.TT; int TD = info.TD; diff --git a/src/main/java/org/rappsilber/fdr/XiCSVinFDR.java b/src/main/java/org/rappsilber/fdr/XiCSVinFDR.java index ab323db..ef68303 100644 --- a/src/main/java/org/rappsilber/fdr/XiCSVinFDR.java +++ b/src/main/java/org/rappsilber/fdr/XiCSVinFDR.java @@ -33,6 +33,7 @@ import org.rappsilber.fdr.entities.PSM; import org.rappsilber.fdr.entities.Peptide; import org.rappsilber.fdr.entities.Protein; +import org.rappsilber.fdr.gui.FDRGUI; import org.rappsilber.utils.IntArrayList; import org.rappsilber.utils.UpdatableChar; import rappsilber.config.RunConfig; @@ -233,14 +234,15 @@ public PSM addMatch(String psmID, String pepSeq1, String pepSeq2, int peplen1, i } public String argList() { - return super.argList() + " --xiconfig=[path to config] --fasta=[path to fasta] --flagModifications"; + return super.argList() + " --xiconfig=[path to config] --fasta=[path to fasta] --flagModifications --gui"; } public String argDescription() { return super.argDescription() + "\n" + "--xiconfig= what xi config to use to turn find modifications\n" + "--fasta= fasta file searched" - + "--flagModifications should modified peptide make their own sub-group\n"; + + "--flagModifications should modified peptide make their own sub-group\n" + + "--gui forward settings to gui\n"; } @@ -248,12 +250,13 @@ public String argDescription() { public String[] parseArgs(String[] argv, FDRSettings settings) { ArrayList unknown = new ArrayList(); argv = super.parseArgs(argv, settings); - + String confpath = null; + boolean startGUI = false; for (String arg : argv) { if (arg.toLowerCase().startsWith("--xiconfig=")) { try { - String confpath=arg.substring("--xiconfig=".length()); - m_config = new RunConfigFile(confpath); + confpath=arg.substring("--xiconfig=".length()); + setConfig(new RunConfigFile(confpath)); } catch (IOException ex) { Logger.getLogger(XiCSVinFDR.class.getName()).log(Level.SEVERE, "Can't read config file:", ex); System.exit(-1); @@ -261,10 +264,11 @@ public String[] parseArgs(String[] argv, FDRSettings settings) { Logger.getLogger(XiCSVinFDR.class.getName()).log(Level.SEVERE, "Error parsing config file:", ex); System.exit(-1); } - + }else if (arg.toLowerCase().contentEquals("--gui")) { + startGUI = true; }else if (arg.toLowerCase().startsWith("--fasta=")) { - String confpath=arg.substring("--fasta=".length()); - searchedFastas.add(confpath); + String fastapath=arg.substring("--fasta=".length()); + searchedFastas.add(fastapath); }else if (arg.toLowerCase().startsWith("--flagmodifications")) { setMarkModifications(true); @@ -273,8 +277,26 @@ public String[] parseArgs(String[] argv, FDRSettings settings) { } } + if (startGUI) { + FDRGUI fg = FDRGUI.startGUI(); + if (unknown.size() > 0) { + fg.setInput(unknown.get(0)); + } + if (searchedFastas.size()>0) { + fg.setFasta(searchedFastas.get(0)); + } + if (confpath != null) { + fg.setXiConfig(confpath); + } + fg.setFDRSettings(settings); + unknown.clear(); + unknown.add("--GUI--"); + + } String[] ret = new String[unknown.size()]; ret = unknown.toArray(ret); + + return ret; } @@ -284,7 +306,8 @@ public static void main (String[] argv) throws SQLException, FileNotFoundExcepti FDRSettings settings = new FDRSettingsImpl(); String[] files = ofdr.parseArgs(argv, settings); - + if (files.length == 1 && files[0].contentEquals("--GUI--")) + return; // assume that everything that was not matched to an argument is a file if (files.length == 0) { @@ -317,8 +340,7 @@ public static void main (String[] argv) throws SQLException, FileNotFoundExcepti } else { ColumnAlternatives.setupAlternatives(csv,CSVinFDR.DEFAULT_COLUMN_MAPPING); } - - + // read in all files for (String f : files) { Logger.getLogger(XiCSVinFDR.class.getName()).log(Level.INFO, "seeting up csv input"); @@ -380,8 +402,8 @@ public RunConfig getConfig() { /** * @param m_config the m_config to set */ - public void setConfig(RunConfig m_config) { - this.m_config = m_config; + public void setConfig(RunConfig config) { + this.m_config = config; crossLinkerMass.clear(); for (rappsilber.ms.crosslinker.CrossLinker cl : m_config.getCrossLinker()) { crossLinkerMass.put(cl.getName(), cl.getCrossLinkedMass()); diff --git a/src/main/java/org/rappsilber/fdr/entities/ProteinGroup.java b/src/main/java/org/rappsilber/fdr/entities/ProteinGroup.java index 51e7b0d..685edde 100644 --- a/src/main/java/org/rappsilber/fdr/entities/ProteinGroup.java +++ b/src/main/java/org/rappsilber/fdr/entities/ProteinGroup.java @@ -137,7 +137,7 @@ private void setFDRGroup() { if (hasInternalSupport) fdrgroup="LinearInternal"; if (fdrgroup.isEmpty()) - fdrgroup = "Between"; + fdrgroup = "Between only"; if (hasNegativeGrouping()) fdrgroup += " [n" + RArrayUtils.toString(getNegativeGrouping(),", n") +"]"; if (hasPositiveGrouping()) diff --git a/src/main/java/org/rappsilber/fdr/gui/FDRGUI.java b/src/main/java/org/rappsilber/fdr/gui/FDRGUI.java index cabf53b..4145b8b 100644 --- a/src/main/java/org/rappsilber/fdr/gui/FDRGUI.java +++ b/src/main/java/org/rappsilber/fdr/gui/FDRGUI.java @@ -55,6 +55,7 @@ import org.rappsilber.data.csv.condition.CsvCondition; import org.rappsilber.fdr.CSVinFDR; import org.rappsilber.fdr.DBinFDR; +import org.rappsilber.fdr.FDRSettings; import org.rappsilber.fdr.result.FDRResult; import org.rappsilber.fdr.result.FDRResultLevel; import org.rappsilber.fdr.MZIdentXLFDR; @@ -1431,6 +1432,51 @@ private void changeFDRSettings(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } + public void setFDRSettings(final FDRSettings settings) { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + rbFDRComplete.setSelected(true); + rbFDRSimple.setSelected(false); + rbFDRCompleteActionPerformed(null); + + fdrSettingsSimple.setAll(settings); + fdrSettingsComplete.setAll(settings); + } + }); + } + + public void setInput(final String fileName) { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + csvSelect.setInputFile(fileName); + } + }); + } + + public void setXiConfig(String fileName) { + csvSelect.setXiConfig(fileName); + } + + public void setFasta(final String fileName) { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + csvSelect.setFasta(fileName); + } + }); + } + + public void setCsvFlagModifications(final boolean flag) { + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + csvSelect.flagModifications(flag); + } + }); + } + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -2912,6 +2958,13 @@ public void run() { * @param args the command line arguments */ public static void main(String args[]) { + + startGUI(); + + } + + public static FDRGUI startGUI() { + /* Set the Nimbus look and feel */ // /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. @@ -2935,13 +2988,15 @@ public static void main(String args[]) { } // // - + + final FDRGUI gui = new FDRGUI(); /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { - new FDRGUI().setVisible(true); + gui.setVisible(true); } }); + return gui; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup bgFDRSettingType; diff --git a/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.form b/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.form index 7cd3db9..44096c9 100644 --- a/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.form +++ b/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.form @@ -208,7 +208,7 @@ - +
@@ -246,6 +246,8 @@ + + @@ -284,6 +286,8 @@ + + @@ -322,6 +326,8 @@ + + @@ -360,6 +366,8 @@ + +
diff --git a/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.java b/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.java index 9356400..3d6b962 100644 --- a/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.java +++ b/src/main/java/org/rappsilber/fdr/gui/components/CSVSelection.java @@ -68,6 +68,10 @@ public class CSVSelection extends javax.swing.JPanel implements Iterable - + @@ -59,20 +59,21 @@ - - - - - - - - - - - + + + + + + + + + + + + @@ -86,7 +87,7 @@ - + @@ -95,7 +96,7 @@ - + @@ -106,7 +107,7 @@ - + @@ -206,6 +207,7 @@ + @@ -312,8 +314,14 @@
+ + + + + + @@ -322,6 +330,11 @@ + + + + + @@ -496,6 +509,7 @@ + @@ -509,5 +523,14 @@ + + + + + + + + + diff --git a/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsComplete.java b/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsComplete.java index 5e9158b..b500f72 100644 --- a/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsComplete.java +++ b/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsComplete.java @@ -427,27 +427,27 @@ public int getMinTD() { @Override public Boolean psmLocalFDR() { - return this.tsLocalPSMFDR.isSelected(); + return this.tsLocalPSMFDR.getSelectionState(); } @Override public Boolean peppairLocalFDR() { - return this.tsLocalPepPairFDR.isSelected(); + return this.tsLocalPepPairFDR.getSelectionState(); } @Override public Boolean protLocalFDR() { - return this.tsLocalProtFDR.isSelected(); + return this.tsLocalProtFDR.getSelectionState(); } @Override public Boolean linkLocalFDR() { - return this.tsLocalLinkFDR.isSelected(); + return this.tsLocalLinkFDR.getSelectionState(); } @Override public Boolean ppiLocalFDR() { - return this.tsLocalPPIFDR.isSelected(); + return this.tsLocalPPIFDR.getSelectionState(); } @Override @@ -542,6 +542,18 @@ public int getMinPeptideFragmentsFilter() { public void setMinPeptideFragmentsFilter(int frags) { this.otherFilter.txtMinPepFrags.setText(Integer.toString(frags)); } + + @Override + public boolean ignoreValidityChecks() { + return this.ckIgnoreValidity.isSelected(); + } + + @Override + public void ignoreValidityChecks(boolean ignore) { + ckIgnoreValidity.setSelected(ignore); + } + + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -595,6 +607,7 @@ private void initComponents() { ckMoreOptions = new javax.swing.JCheckBox(); spOtherFilter = new javax.swing.JScrollPane(); otherFilter = new org.rappsilber.fdr.gui.components.OtherFilter(); + ckIgnoreValidity = new javax.swing.JCheckBox(); jLabel5.setText("PSM"); @@ -628,9 +641,15 @@ private void initComponents() { jLabel28.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel28.setText("Min supporting peptide-pairs"); + spMaxLinkAmbiguity.setToolTipText("maximum ambiguity for a peptide-pair giving raise to a residue pair"); + + spMaxProteinAmbiguity.setToolTipText("maximum number of proteins a peptide could originate from (this ignores if a peptide could come from several places within a protein)"); + jLabel1.setText("Local FDR"); jLabel1.setToolTipText("ticked calculate and filtert by PEP; unticked: do not calculate calculate PEP; square: calculate PEP but do not filter (default)"); + spMinPeptideLength.setToolTipText("matches to involving\u0000 peptides shorter then this will be ignored"); + jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel18.setText("Min Pep. Length:"); @@ -724,6 +743,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { tsLocalPPIFDR.setToolTipText("calculate (PEP) (square); calculate and filter by PEP (tick); or do not calculate PEP"); ckMoreOptions.setText("More"); + ckMoreOptions.setToolTipText("some addtional optional prefilter"); ckMoreOptions.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ckMoreOptionsActionPerformed(evt); @@ -732,6 +752,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { spOtherFilter.setViewportView(otherFilter); + ckIgnoreValidity.setText("Ignore Validity Checks"); + ckIgnoreValidity.setToolTipText("Sub-groups with e.g. negative calculated FDR or to few target matches for the requested FDR)"); + ckIgnoreValidity.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ckIgnoreValidityActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -772,18 +800,19 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(tsLocalLinkFDR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tsLocalPepPairFDR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tsLocalPSMFDR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(tsLocalProtFDR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spMinPPIPepCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(spMinLinkPepCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(spMinProteinPepCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) - .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE) - .addComponent(spMinTDChance, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(tsLocalProtFDR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(ckMoreOptions)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(ckMoreOptions) - .addGap(0, 0, Short.MAX_VALUE))) + .addComponent(ckIgnoreValidity) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(spMinPPIPepCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spMinLinkPepCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spMinProteinPepCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spMinTDChance, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(spMaxLinkAmbiguity, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -795,13 +824,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(ckGroupByPSMs) .addComponent(ckUniquePSM) .addComponent(ckFilterConsecutives)) - .addGap(0, 56, Short.MAX_VALUE)))) + .addGap(0, 0, Short.MAX_VALUE)))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(ckMaximize) .addGap(12, 12, 12) - .addComponent(cbBoostWhat, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)) + .addComponent(cbBoostWhat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(btnStopBoost)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel23) @@ -810,7 +839,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createSequentialGroup() .addGap(70, 70, 70) .addComponent(btnBoostIgnores) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 260, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnCalc)) .addGroup(layout.createSequentialGroup() .addComponent(spMaximizeSteps) @@ -882,7 +911,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ckFilterConsecutives) - .addComponent(ckMoreOptions)) + .addComponent(ckMoreOptions) + .addComponent(ckIgnoreValidity)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(spOtherFilter, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE) .addGap(18, 18, 18) @@ -936,6 +966,10 @@ private void ckMoreOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN this.revalidate(); }//GEN-LAST:event_ckMoreOptionsActionPerformed + private void ckIgnoreValidityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ckIgnoreValidityActionPerformed + spMinTDChance.setEnabled(!ckIgnoreValidity.isSelected()); + }//GEN-LAST:event_ckIgnoreValidityActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnBoostIgnores; private javax.swing.JButton btnCalc; @@ -944,6 +978,7 @@ private void ckMoreOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN private javax.swing.JCheckBox ckBoostBetween; private javax.swing.JCheckBox ckFilterConsecutives; private javax.swing.JCheckBox ckGroupByPSMs; + private javax.swing.JCheckBox ckIgnoreValidity; private javax.swing.JCheckBox ckMaximize; private javax.swing.JCheckBox ckMoreOptions; private javax.swing.JCheckBox ckUniquePSM; diff --git a/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsSimple.java b/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsSimple.java index 839f0b2..1bc7f12 100644 --- a/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsSimple.java +++ b/src/main/java/org/rappsilber/fdr/gui/components/FDRSettingsSimple.java @@ -56,6 +56,7 @@ public class FDRSettingsSimple extends FDRSettingsPanel { private boolean combineScoreAndDelta; private int minFragments; private boolean boostMinFragments; + private boolean ignoreValidityChecks; @Override public boolean getBoostBetween() { @@ -647,6 +648,16 @@ public void setMinPeptideFragmentsFilter(int frags) { this.minFragments = frags; } + @Override + public boolean ignoreValidityChecks() { + return this.ignoreValidityChecks; + } + + @Override + public void ignoreValidityChecks(boolean ignore) { + this.ignoreValidityChecks = ignore; + } + } diff --git a/src/main/java/org/rappsilber/fdr/result/FDRResult.java b/src/main/java/org/rappsilber/fdr/result/FDRResult.java index 781dfdf..7da16e8 100644 --- a/src/main/java/org/rappsilber/fdr/result/FDRResult.java +++ b/src/main/java/org/rappsilber/fdr/result/FDRResult.java @@ -15,6 +15,7 @@ */ package org.rappsilber.fdr.result; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import org.rappsilber.fdr.entities.PSM; @@ -40,6 +41,7 @@ public class FDRResult { public int maximumLinkAmbiguity = 0; public double reportFactor = 0; public boolean uniquePSMs = false; + public ArrayList excludedGroups = new ArrayList(); public void clear() { if (psmFDR != null) diff --git a/src/main/resources/xifdrproject.properties b/src/main/resources/xifdrproject.properties index 7b6e503..586133a 100644 --- a/src/main/resources/xifdrproject.properties +++ b/src/main/resources/xifdrproject.properties @@ -1,6 +1,12 @@ xifdr.version=${project.version} xifdr.artifactId=${project.artifactId} xifdr.changelog=\ +1.3.37\n\ +* BUGFIX local FDR not working correctly\n\ +* Forward arguments from command-line to GUI\n\ +* min number of fragments readable from csv\n\ +* validity checks can be switched off\n\ +* gives feedback on what sub-groups got dropped\n\ 1.3.36\n\ * changing the logging detail should no longer hang hang up the gui\n\ * Noncovalents are no longer forwarded to Links and PPIs.\n\