diff --git a/.gitattributes b/.gitattributes index 5ba244a881..af623e919c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -727,11 +727,6 @@ ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocolFactory.java -text ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchTask.java -text ms2/src/org/labkey/ms2/pipeline/mascot/setMascotDefaults.jsp -text ms2/src/org/labkey/ms2/pipeline/phenyx/PhenyxRun.java -text -ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupDefaults.xml -text -ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineJob.java -text -ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineProvider.java -text -ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocol.java -text -ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocolFactory.java -text ms2/src/org/labkey/ms2/pipeline/sequest/AbstractMultipleValueParamsValidator.java -text ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestParams.java -text ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestSearchTaskFactory.java -text diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/Search.gwt.xml b/ms2/gwtsrc/org/labkey/ms2/pipeline/Search.gwt.xml deleted file mode 100644 index dccc497963..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/Search.gwt.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/CutSite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/CutSite.java deleted file mode 100644 index 330efa63ef..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/CutSite.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2008-2011 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -/** - * User: billnelson@uky.edu - * Date: Apr 24, 2008 - */ - -/** - * CutSite - */ -public class CutSite -{ - private char[] cuts; - private char[] noCuts; - private String signature; - private boolean nTerm; - - public CutSite(char[] cuts, char[] noCuts, String signature, boolean nTermCut) - { - this.cuts = cuts; - this.noCuts = noCuts; - this.signature = signature; - this.nTerm = nTermCut; - } - - public CutSite(String cutSite) - { - if(cutSite == null) throw new EnzymeParseException("null"); - - cutSite = cutSite.trim(); - String[] split = cutSite.split("\\|"); - if(split.length != 2) throw new EnzymeParseException("Invalid cut site definition: '" + cutSite + "'."); - int length1 = split[0].length(); - int length2 = split[1].length(); - char c1 = split[0].charAt(0); - char c2 = split[0].charAt(length1 - 1); - char c3 = split[1].charAt(0); - char c4 = split[1].charAt(length2 - 1); - - if(c1 == '{' && c2 == '}') - { - throw new EnzymeParseException("Invalid cut site definition: '" + cutSite + "'."); - } - else if(c1 == '[' && c2 == ']') - { - loadCuts(split[0]); - if(c3 == '{' && c4 == '}') - { - loadNoCuts(split[1]); - } - else if(c3 == '[' && c4 == ']') - { - if(cuts[0] == 'X' && cuts.length == 1) - { - nTerm = true; - loadCuts(split[1]); - noCuts = new char[]{}; - } - else if(split[1].charAt(1) == 'X') - { - noCuts = new char[]{}; - } - else - { - throw new EnzymeParseException("Invalid cut site definition: '" + cutSite + "'."); - } - } - else - { - throw new EnzymeParseException("Invalid cut site definition: '" + cutSite + "'."); - } - } - else throw new EnzymeParseException("Invalid cut site definition: '" + cutSite + "'."); - signature = cutSite; - } - - private void loadCuts(String chars) - { - if(chars == null)return; - chars = chars.substring(1,chars.length() -1); - int cutCount = chars.length(); - cuts = new char[cutCount]; - for(int i = 0; i < cutCount; i++) - { - cuts[i] = chars.charAt(i); - } - } - - private void loadNoCuts(String chars) - { - if(chars == null)return; - chars = chars.substring(1,chars.length() -1); - int cutCount = chars.length(); - noCuts = new char[cutCount]; - for(int i = 0; i < cutCount; i++) - { - noCuts[i] = chars.charAt(i); - } - } - - - - public char[] getCuts() - { - return cuts; - } - - public void setCuts(char[] cuts) - { - this.cuts = cuts; - } - - public boolean isNTerm() - { - return nTerm; - } - - public void setNTerm(boolean nTerm) - { - this.nTerm = nTerm; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - public char[] getNoCuts() - { - return noCuts; - } - - public void setNoCuts(char[] noCuts) - { - this.noCuts = noCuts; - } - - public boolean equals(Object o) - { - if (this == o) return true; -// String classNameThis = GWT.getTypeName(this); -// String classNameO = GWT.getTypeName(o); -// if (o == null || !classNameThis.equals(classNameO)) return false; - CutSite cutSite = (CutSite) o; - - if(!arrayEquals(cuts, cutSite.cuts)) return false; - if(!arrayEquals(noCuts, cutSite.noCuts)) return false; - if(cuts.length == 1 && noCuts.length == 1) - if(cuts[0] == 'X' && noCuts[0] == 'X') return true; - return nTerm == cutSite.nTerm; - } - - private boolean arrayEquals(char[] c1, char[] c2) - { - if(c1 == c2 && c1 == null) return true; - if(c1 == null || c2 == null) return false; - if(c1.length != c2.length) return false; - sort(c1); - sort(c2); - for(int i = 0; i < c1.length; i++) - { - if(c1[i] != c2[i]) return false; - } - return true; - } - - private void sort(char[] c) { - int n = c.length; - for (int pass=1; pass < n; pass++) - { - for (int i=0; i < n-pass; i++) - { - if (c[i] > c[i+1]) - { - char temp = c[i]; - c[i] = c[i+1]; - c[i+1] = temp; - } - } - } - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/Enzyme.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/Enzyme.java deleted file mode 100644 index a5da718c22..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/Enzyme.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2008-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -/** - * User: billnelson@uky.edu - * Date: Apr 24, 2008 - */ - -/** - * Enzyme - */ -public class Enzyme -{ - private String displayName; - private String[] names; - private CutSite[] cutSite; - - public Enzyme(String displayName, String[] names, CutSite[] cutSite) - { - this.displayName = displayName; - this.names = names; - this.cutSite = cutSite; - } - - public Enzyme(String signature) - { - String sigSites[] = signature.split(","); - int numSites = sigSites.length; - cutSite = new CutSite[numSites]; - for(int i = 0; i < numSites; i++) - { - cutSite[i] = new CutSite(sigSites[i]); - } - } - - public String getDisplayName() - { - return displayName; - } - - public void setDisplayName(String displayName) - { - this.displayName = displayName; - } - - public String[] getNames() - { - return names; - } - - public void setNames(String[] names) - { - this.names = names; - } - - public CutSite[] getCutSite() - { - return cutSite; - } - - public void setCutSite(CutSite[] cutSite) - { - this.cutSite = cutSite; - } - - public boolean equals(Object o) - { - if (this == o) return true; - if (!(o instanceof Enzyme)) - { - return false; - } - - Enzyme enzyme = (Enzyme) o; - - if(cutSite.length != enzyme.cutSite.length) return false; - for (CutSite aCutSite : cutSite) - { - boolean same = false; - for (int y = 0; y < cutSite.length; y++) - { - if (aCutSite.equals(enzyme.cutSite[y])) - { - same = true; - break; - } - } - if (!same) return false; - } - if(displayName != null) - if(displayName.equalsIgnoreCase(enzyme.displayName)) return true; - - if(names == enzyme.names)return true; - if(names != null && enzyme.names != null) - { - for (String name : names) - { - for (int y = 0; y < enzyme.names.length; y++) - { - if (name.equalsIgnoreCase(enzyme.names[y])) - { - return true; - } - } - } - return false; - } - else - { - if(enzyme.names != null) - { - for(int i = 0; i < enzyme.names.length; i++) - { - if(displayName.equalsIgnoreCase(enzyme.names[i])) - { - return true; - } - } - return false; - - } - } - return true; - } - - public String toString() - { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < cutSite.length; i++) - { - if(i < 0) sb.append(", "); - sb.append(cutSite[i].getSignature()); - } - return sb.toString(); - } -} \ No newline at end of file diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/EnzymeComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/EnzymeComposite.java deleted file mode 100644 index 8b8782d1a4..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/EnzymeComposite.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (c) 2008-2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.user.client.ui.*; -import org.labkey.api.gwt.client.ui.HelpPopup; - -import java.util.*; - -/** - * User: billnelson@uky.edu - * Date: Apr 24, 2008 - */ - -/** - * EnzymeComposite - */ -public class EnzymeComposite extends SearchFormComposite -{ - protected VerticalPanel instance = new VerticalPanel(); - protected ListBox enzymeListBox = new ListBox(); - protected Map> enzymes = new HashMap>(); - protected Label enzymeReadOnly = new Label(); - - public EnzymeComposite() - { - enzymeListBox.setVisibleItemCount(1); - enzymeReadOnly.setStylePrimaryName("labkey-read-only"); - instance.add(enzymeListBox); - initWidget(instance); - } - - public void update(Map> enzymeMap) - { - if(enzymeMap == null) return; - Set keySet = enzymeMap.keySet(); - ArrayList sorted = new ArrayList(keySet); - Collections.sort(sorted); - enzymeListBox.clear(); - enzymes = enzymeMap; - - for(String name : sorted) - { - List value = enzymeMap.get(name); - // Add just the "canonical" enzyme signature - enzymeListBox.addItem(name, value.get(0)); - } - setSelectedEnzymeByName("Trypsin"); - } - - - @Override - public void setWidth(String width) - { - instance.setWidth(width); - enzymeListBox.setWidth(width); - enzymeReadOnly.setWidth(width); - } - - @Override - public Widget getLabel() - { - Label label = new Label("Enzyme"); - label.setStylePrimaryName(LABEL_STYLE_NAME); - HorizontalPanel panel = new HorizontalPanel(); - panel.add(label); - panel.add(new HelpPopup("Enzyme", "Short peptides are generated from longer protein sequences by the use of either chemical or enzymatic cleavage. Both types of cleavage tend to have preferred sites of cleavage, based on the residues on either side of the peptide bond to be cleaved. Proteomics experiments frequently use enzymes with very strong sequence specificity, to limit the number of peptides generated and the assure that there are a reasonable number of peptides in the length range most useful for protein identification.
Text taken from the X!Tandem documentation.
")); - return panel; - } - - @Override - public String validate() - { - return ""; - } - - @Override - public void setName(String s) - { - enzymeListBox.setName(s); - } - - @Override - public String getName() - { - return enzymeListBox.getName(); - } - - public String getSelectedEnzyme() - { - int index = enzymeListBox.getSelectedIndex(); - if(index == -1) return ""; - return enzymeListBox.getValue(index); - } - - public String setSelectedEnzymeByName(String enzyme) - { - - int enzCount = enzymeListBox.getItemCount(); - boolean foundEnz = false; - for(int i = 0; i < enzCount; i++) - { - if(enzyme.equals(enzymeListBox.getItemText(i))) - { - enzymeListBox.setSelectedIndex(i); - foundEnz = true; - } - } - if(!foundEnz) - return "The enzyme '" + enzyme + "' was not found."; - return ""; - } - - public String setSelectedEnzyme(String enzymeSignature) - { - try - { - new Enzyme(enzymeSignature); - } - catch(EnzymeParseException e) - { - return e.getMessage(); - } - return findEnzyme(enzymeSignature); - } - - private String findEnzyme(String enzymeSignature) - { - int enzCount = enzymeListBox.getItemCount(); - boolean foundEnz = false; - - String canonicalSignature = null; - - for (Map.Entry> entry : enzymes.entrySet()) - { - if (entry.getValue().contains(enzymeSignature)) - { - canonicalSignature = entry.getValue().get(0); - break; - } - } - if(canonicalSignature == null) - return "The enzyme '" + enzymeSignature + "' was not found."; - - for(int i = 0; i < enzCount; i++) - { - try - { - String listBoxValue = enzymeListBox.getValue(i); - // Create to see if it parses - new Enzyme(listBoxValue); - if(canonicalSignature.equals(listBoxValue)) - { - enzymeListBox.setSelectedIndex(i); - foundEnz = true; - } - } - catch(EnzymeParseException e) - { - return e.getMessage(); - } - } - if(!foundEnz) - return "The enzyme '" + enzymeSignature + "' was not found."; - return ""; - } - - @Override - public void setReadOnly(boolean readOnly) - { - super.setReadOnly(readOnly); - - if(readOnly) - { - int index = enzymeListBox.getSelectedIndex(); - if(index != -1) - { - String enzymeName = enzymeListBox.getItemText(index); - enzymeReadOnly.setText(enzymeName); - } - else - { - enzymeReadOnly.setText(" "); - } - instance.remove(enzymeListBox); - instance.insert(enzymeReadOnly, 0); - } - else - { - instance.remove(enzymeReadOnly); - instance.add(enzymeListBox); - } - } - - public void addChangeListener(ChangeHandler changeHandler) - { - enzymeListBox.addChangeHandler(changeHandler); - } - - @Override - public void syncFormToXml(ParamParser params) throws SearchFormException - { - params.setInputParameter(ParameterNames.ENZYME, getSelectedEnzyme()); - } - - @Override - public String syncXmlToForm(ParamParser params) - { - String enzyme = params.getInputParameter(ParameterNames.ENZYME); - if(enzyme == null || enzyme.equals("")) - { - enzyme = getSelectedEnzyme(); - if(enzyme == null || enzyme.equals("")) - { - return ""; - } - else - { - try - { - params.setInputParameter(ParameterNames.ENZYME, enzyme); - } - catch(SearchFormException e) - { - return "Cannot set the enzyme in XML: " + e.getMessage(); - } - } - } - else if(!enzyme.equals(getSelectedEnzyme())) - { - return setSelectedEnzyme(enzyme); - } - return ""; - } - - @Override - public Set getHandledParameterNames() - { - return Collections.singleton(ParameterNames.ENZYME); - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/EnzymeParseException.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/EnzymeParseException.java deleted file mode 100644 index ab4c47ae32..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/EnzymeParseException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2008 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -/** - * User: billnelson@uky.edu - * Date: Apr 26, 2008 - */ - -/** - * EnzymeParseException - */ -public class EnzymeParseException extends RuntimeException -{ - - public EnzymeParseException() - { - super(); - } - - public EnzymeParseException(String s) - { - super(s); - } - - public EnzymeParseException(String s, Throwable throwable) - { - super(s, throwable); - } - - public EnzymeParseException(Throwable throwable) - { - super(throwable); - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/GWTSearchServiceResult.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/GWTSearchServiceResult.java deleted file mode 100644 index 8aba7bff34..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/GWTSearchServiceResult.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2008-2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.List; -import java.util.Map; - -/** - * User: billnelson@uky.edu - * Date: Feb 14, 2008 - */ - -public class GWTSearchServiceResult implements IsSerializable -{ - private List sequenceDBs; - private String currentPath; - - private List sequenceDbPaths; - private List mascotTaxonomyList; - - private Map> enzymeMap; - - private Map mod0Map; - - private Map mod1Map; - - private String defaultSequenceDb; - - private String selectedProtocol; - private List protocols; - - private String protocolDescription; - - private String protocolXml; - private List fileInputNames; - - private List fileInputStatus; - - private boolean activeJobs; - - private String errors = ""; - - - public String getSelectedProtocol() - { - return selectedProtocol; - } - - public void setSelectedProtocol(String selectedProtocol) - { - this.selectedProtocol = selectedProtocol; - } - - public List getSequenceDBs() - { - return sequenceDBs; - } - public void setSequenceDbs(List sequenceDbs, String currentPath) - { - this.sequenceDBs = sequenceDbs; - this.currentPath = currentPath; - } - - public String getCurrentPath() - { - return currentPath; - } - - public List getSequenceDbPaths() - { - return sequenceDbPaths; - } - - public void setSequenceDbPaths(List sequenceDbPaths) - { - this.sequenceDbPaths = sequenceDbPaths; - } - - public List getProtocols() - { - return protocols; - } - - public void setProtocols(List protocols) - { - this.protocols = protocols; - } - - public String getErrors() - { - return errors; - } - - public void appendError(String error) - { - if(error.trim().length() == 0) return; - if(errors.length() > 0) - errors += "\n"; - errors += error; - } - - public String getDefaultSequenceDb() - { - return defaultSequenceDb; - } - - public void setDefaultSequenceDb(String defaultSequenceDb) - { - this.defaultSequenceDb = defaultSequenceDb; - } - - public String getProtocolXml() - { - if(protocolXml == null || protocolXml.length() == 0) - return ""; - return protocolXml; - } - - public void setProtocolXml(String protocolXml) - { - this.protocolXml = protocolXml; - } - - public String getProtocolDescription() - { - return protocolDescription; - } - - public void setProtocolDescription(String protocolDescription) - { - this.protocolDescription = protocolDescription; - } - - public List getFileInputNames() - { - return fileInputNames; - } - - public void setFileInputNames(List names) - { - this.fileInputNames = names; - } - - public List getFileInputStatus() - { - return fileInputStatus; - } - - public void setFileInputStatus(List fileInputStatus) - { - this.fileInputStatus = fileInputStatus; - } - - public boolean isActiveJobs() - { - return activeJobs; - } - - public void setActiveJobs(boolean activeJobs) - { - this.activeJobs = activeJobs; - } - - public Map> getEnzymeMap() - { - return enzymeMap; - } - - public void setEnzymeMap(Map> enzymeMap) - { - this.enzymeMap = enzymeMap; - } - - public Map getMod0Map() - { - return mod0Map; - } - - public void setMod0Map(Map mod0Map) - { - this.mod0Map = mod0Map; - } - - public Map getMod1Map() - { - return mod1Map; - } - - public void setMod1Map(Map mod1Map) - { - this.mod1Map = mod1Map; - } - - - public List getMascotTaxonomyList() - { - return mascotTaxonomyList; - } - - public void setMascotTaxonomyList(List mascotTaxonomyList) - { - this.mascotTaxonomyList = mascotTaxonomyList; - } - -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/GeneralInputXmlComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/GeneralInputXmlComposite.java deleted file mode 100644 index adee7db2c2..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/GeneralInputXmlComposite.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Widget; -import org.labkey.api.gwt.client.ui.HelpPopup; - -/** - * User: billnelson@uky.edu - * Date: Apr 18, 2008 - */ - -public class GeneralInputXmlComposite extends InputXmlComposite -{ - private final String _description; - private final String _helpTopic; - - public GeneralInputXmlComposite(String description, String helpTopic) - { - _description = description; - _helpTopic = helpTopic; - } - - @Override - public String update(String text) - { - if(params == null) - params = new ParamParser(inputXmlTextArea); - return super.update(text); - } - - @Override - public Widget getLabel() - { - Label label = new Label(_description); - label.setStyleName(LABEL_STYLE_NAME); - HorizontalPanel panel = new HorizontalPanel(); - panel.add(label); - panel.add(new HelpPopup(_description, "The full set of analysis parameters, represented in XML.")); - return panel; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/InputXmlComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/InputXmlComposite.java deleted file mode 100644 index 3e49319e4f..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/InputXmlComposite.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2008-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Hidden; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.TextArea; -import org.labkey.api.gwt.client.util.StringUtils; - -/** - * User: billnelson@uky.edu - * Date: Apr 8, 2008 - */ -public abstract class InputXmlComposite extends SearchFormComposite -{ - protected TextAreaWrappable inputXmlTextArea = new TextAreaWrappable(); - protected Hidden inputXmlHidden = new Hidden(); - protected HTML inputXmlHtml = new HTML(); - protected HorizontalPanel instance = new HorizontalPanel(); - protected ParamParser params; - public static final String DEFAULT_XML = "\n" + - "\n" + - "\n" + - ""; - - public InputXmlComposite() - { - inputXmlTextArea.setVisibleLines(10); - inputXmlTextArea.setWrap("OFF"); - inputXmlHtml.setStylePrimaryName("labkey-read-only"); - instance.add(inputXmlTextArea); - initWidget(instance); - } - - public void setDefault() - { - update(DEFAULT_XML); - } - - public String update(String text) - { - if(text.equals("")) - text = DEFAULT_XML; - inputXmlTextArea.setText(text); - return validate(); - } - - @Override - public void setReadOnly(boolean readOnly) { - super.setReadOnly(readOnly); - if(readOnly) - { - instance.remove(inputXmlTextArea); - String text = inputXmlTextArea.getText(); - inputXmlHidden.setName(getName()); - inputXmlHidden.setValue(text); - inputXmlHtml.setHTML(StringUtils.filter(text,true)); - instance.add(inputXmlHidden); - instance.add(inputXmlHtml); - } - else - { - instance.remove(inputXmlHidden); - instance.remove(inputXmlHtml); - instance.add(inputXmlTextArea); - } - } - - @Override - public String getName() - { - return inputXmlTextArea.getName(); - } - - @Override - public void setName(String name) - { - inputXmlTextArea.setName(name); - } - - @Override - public void setWidth(String width) - { - instance.setWidth(width); - inputXmlTextArea.setWidth(width); - inputXmlHtml.setWidth(width); - } - - @Override - public String validate() - { - return params.validate(); - } - - public void addChangeListener(ChangeHandler changeHandler) - { - inputXmlTextArea.addChangeHandler(changeHandler); - } - - public void writeXml() throws SearchFormException - { - params.writeXml(); - } - - @Override - public void syncFormToXml(ParamParser params) - { - throw new UnsupportedOperationException(); - } - - @Override - public String syncXmlToForm(ParamParser params) - { - throw new UnsupportedOperationException(); - } - - private static class TextAreaWrappable extends TextArea - { - public void setWrap(String wrapOption) - { - Element textArea = getElement(); - DOM.setElementAttribute(textArea,"wrap", wrapOption); - } - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/MzXmlComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/MzXmlComposite.java deleted file mode 100644 index c07d8964be..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/MzXmlComposite.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2008-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; - -import java.util.Iterator; -import java.util.List; - -/** - * User: billnelson@uky.edu - * Date: Mar 31, 2008 - */ -public class MzXmlComposite extends SearchFormComposite -{ - VerticalPanel instance = new VerticalPanel(); - private boolean hasWork; - private boolean hasRun; - private List _fileInputNames; - - public MzXmlComposite() - { - initWidget(instance); - } - - public void update(List fileInputNames, List fileInputStatus, boolean isActiveJobs) - { - hasRun = false; - hasWork = !isActiveJobs; - // Stash for refreshing without getting a new list of files - _fileInputNames = fileInputNames; - - instance.clear(); - int num = (fileInputNames == null ? 0 : fileInputNames.size()); - if(num != 0) - { - StringBuilder names = new StringBuilder(); - for(int i = 0; i < num; i++) - { - if (i > 0) - names.append("
"); - names.append(fileInputNames.get(i)); - if(fileInputStatus != null && i < fileInputStatus.size()) - { - String status = fileInputStatus.get(i); - if (status != null && !"".equals(status)) - { - names.append(" (").append(status).append(")"); - hasRun = true; - } - } - } - HTML html = new HTML(names.toString()); - html.setStylePrimaryName("labkey-read-only"); - instance.add(html); - } - else - { - instance.add(new Label("No mzXML files found")); - } - } - - @Override - public String getName() - { - return null; //Not needed. Just Labels. - } - - @Override - public void setName(String s) - { - //Not needed. Just Labels. - } - - @Override - public void setWidth(String width) - { - //defaults are okay for now - } - - @Override - public Widget getLabel() - { - Label label = new Label("Input file(s)"); - label.setStylePrimaryName(LABEL_STYLE_NAME); - return label; - } - - @Override - public String validate() - { - return null; //No need for now. - } - - public boolean hasWork() - { - return hasWork; - } - - public void setHasWork(boolean hasWork) - { - this.hasWork = hasWork; - } - - public boolean hasRun() - { - return hasRun; - } - - public void setHasRun(boolean hasRun) - { - this.hasRun = hasRun; - } - - public void clearStatus() - { - update(_fileInputNames, null, false); - } - - @Override - public void syncFormToXml(ParamParser params) - { - - } - - @Override - public String syncXmlToForm(ParamParser params) - { - return ""; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/OtherParametersComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/OtherParametersComposite.java deleted file mode 100644 index 171343d138..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/OtherParametersComposite.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2012-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.event.dom.client.BlurEvent; -import com.google.gwt.event.dom.client.BlurHandler; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.FocusEvent; -import com.google.gwt.event.dom.client.FocusHandler; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyPressEvent; -import com.google.gwt.event.dom.client.KeyPressHandler; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; -import org.labkey.api.gwt.client.ui.FontButton; -import org.labkey.api.gwt.client.ui.HelpPopup; -import org.labkey.api.gwt.client.ui.ImageButton; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * User: jeckels - * Date: Jan 30, 2012 - */ -public class OtherParametersComposite extends SearchFormComposite -{ - protected FlexTable _table = new FlexTable(); - Map _inputs = new LinkedHashMap(); - private TextBox _newParameterNameTextBox = new TextBox(); - private ImageButton _newParameterButton = new ImageButton("Add"); - private ChangeHandler _handler; - public static final String BLANK_PARAMETER_NAME_PROMPT = ""; - private final List _uiElements; - private final InputXmlComposite _inputXmlComposite; - - public OtherParametersComposite(List uiElements, InputXmlComposite inputXmlComposite) - { - _uiElements = uiElements; - _inputXmlComposite = inputXmlComposite; - _newParameterNameTextBox.addBlurHandler(new BlurHandler() - { - @Override - public void onBlur(BlurEvent event) - { - if (_newParameterNameTextBox.getText().trim().isEmpty()) - { - _newParameterNameTextBox.setText(BLANK_PARAMETER_NAME_PROMPT); - DOM.setStyleAttribute(_newParameterNameTextBox.getElement(), "color", "grey"); - } - } - }); - - _newParameterButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - addParameter(); - } - }); - _newParameterNameTextBox.addKeyPressHandler(new KeyPressHandler() - { - @Override - public void onKeyPress(KeyPressEvent event) - { - if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) - { - addParameter(); - } - } - }); - - _newParameterNameTextBox.addFocusHandler(new FocusHandler() - { - @Override - public void onFocus(FocusEvent event) - { - if (BLANK_PARAMETER_NAME_PROMPT.equals(_newParameterNameTextBox.getText())) - { - _newParameterNameTextBox.setText(""); - } - DOM.setStyleAttribute(_newParameterNameTextBox.getElement(), "color", ""); - } - }); - _newParameterNameTextBox.setText(BLANK_PARAMETER_NAME_PROMPT); - DOM.setStyleAttribute(_newParameterNameTextBox.getElement(), "color", "grey"); - _newParameterNameTextBox.setWidth("20em"); - - _table.setStylePrimaryName("lk-fields-table"); - _table.setCellPadding(1); - initWidget(_table); - } - - private void addParameter() - { - String name = _newParameterNameTextBox.getText().trim(); - if (!name.isEmpty() && !name.equals(BLANK_PARAMETER_NAME_PROMPT)) - { - if (isHandledParameter(name)) - { - new Search.ErrorDialogBox("Please set the '" + name + "' parameter by using the user interface above"); - return; - } - if (!_inputs.containsKey(name)) - { - Label label = new Label(name); - _table.setWidget(_table.getRowCount() - 1, 0, label); - _table.getCellFormatter().setStylePrimaryName(_table.getRowCount() - 1, 0, "labkey-form-label-nowrap"); - TextBox textBox = createParameterValueTextBox(); - _inputs.put(name, textBox); - _table.setWidget(_table.getRowCount() - 1, 1, textBox); - _table.setWidget(_table.getRowCount() - 1, 2, createDeleteButton(name)); - _table.setWidget(_table.getRowCount(), 0, _newParameterNameTextBox); - _table.setWidget(_table.getRowCount() - 1, 1, _newParameterButton); - _newParameterNameTextBox.setText(""); - _newParameterNameTextBox.setText(BLANK_PARAMETER_NAME_PROMPT); - DOM.setStyleAttribute(_newParameterNameTextBox.getElement(), "color", "grey"); - _handler.onChange(null); - textBox.setFocus(true); - } - else - { - new Search.ErrorDialogBox("Duplicate parameter name"); - } - } - } - - @Override - public void setWidth(String width) - { - } - - @Override - public Widget getLabel() - { - Label label = new Label("Other parameters"); - label.setStyleName(LABEL_STYLE_NAME); - HorizontalPanel panel = new HorizontalPanel(); - panel.add(label); - panel.add(new HelpPopup("Other parameters", "The names and values of other analysis parameters that are not controlled by the above inputs.")); - return panel; - } - - @Override - public String validate() - { - return ""; - } - - @Override - public void syncFormToXml(ParamParser params) throws SearchFormException - { - for (Map.Entry entry : _inputs.entrySet()) - { - params.setInputParameter(entry.getKey(), entry.getValue().getText()); - } - } - - @Override - public void setReadOnly(boolean readOnly) - { - super.setReadOnly(readOnly); - createTable(); - } - - @Override - public String syncXmlToForm(ParamParser params) - { - _inputs.clear(); - for (Map.Entry entry : params.getParameters().entrySet()) - { - if (!isHandledParameter(entry.getKey())) - { - TextBox valueBox = createParameterValueTextBox(); - valueBox.setText(entry.getValue()); - _inputs.put(entry.getKey(), valueBox); - } - } - createTable(); - return ""; - } - - private boolean isHandledParameter(String name) - { - for (SearchFormComposite uiElement : _uiElements) - { - if (uiElement.isHandledParameterName(name)) - { - return true; - } - } - return false; - } - - - private TextBox createParameterValueTextBox() - { - TextBox valueBox = new TextBox(); - valueBox.setWidth("20em"); - valueBox.addChangeHandler(_handler); - return valueBox; - } - - private void createTable() - { - int row = 0; - _table.removeAllRows(); - for (final Map.Entry entry : _inputs.entrySet()) - { - Label label = new Label(entry.getKey()); - - _table.setWidget(row, 0, label); - _table.getCellFormatter().setStylePrimaryName(row, 0, "labkey-form-label-nowrap"); - - if (readOnly) - { - _table.setText(row, 1, entry.getValue().getText()); - } - else - { - _table.setWidget(row, 1, entry.getValue()); - FontButton deleteButton = createDeleteButton(entry.getKey()); - _table.setWidget(row, 2, deleteButton); - } - row++; - } - - if (!readOnly) - { - _table.setWidget(++row, 0, _newParameterNameTextBox); - _table.setWidget(row, 1, _newParameterButton); - } - - } - - private FontButton createDeleteButton(final String paramName) - { - FontButton button = new FontButton("fa-times"); - String id = "partdelete_" + paramName; - button.getElement().setId(id); - button.addClickHandler(clickEvent -> { - _inputXmlComposite.params.removeInputParameter(paramName); - _inputs.remove(paramName); - createTable(); - _handler.onChange(null); - - }); - return button; - } - - @Override - public void setName(String name) - { - - } - - @Override - public String getName() - { - return null; - } - - public void addChangeListener(ChangeHandler handler) - { - _handler = handler; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ParamParser.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ParamParser.java deleted file mode 100644 index 98c63664c1..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ParamParser.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2008-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.xml.client.*; -import com.google.gwt.xml.client.impl.DOMParseException; -import com.google.gwt.user.client.ui.HasText; - -import java.util.*; - -/** - * User: billnelson@uky.edu - * Date: Apr 21, 2008 - */ - -/** - * ParamParser - */ -public class ParamParser -{ - public static String TAG_BIOML = "bioml"; - public static String TAG_NOTE = "note"; - public static String ATTR_LABEL = "label"; - public static String ATTR_TYPE = "type"; - public static String VAL_INPUT = "input"; - protected static String XML_HEADER = "\n" + - "\n"; - protected static String XML_FOOTER = ""; - - StringBuffer error; - Document xmlDoc; - HasText xmlWrapper; - - public ParamParser(HasText xml) - { - xmlWrapper = xml; - } - - private void appendError(String s) - { - if(this.error == null) - this.error = new StringBuffer(); - if(error.length() > 0) error.append("\n"); - error.append(s); - } - - public String toXml()throws SearchFormException - { - NodeList nodes = getAllNodes(); - if(nodes == null || nodes.getLength() == 0 ) return ""; - StringBuffer sb = new StringBuffer(); - sb.append(XML_HEADER); - int nodeCount = nodes.getLength(); - for(int i = 0; i < nodeCount; i++) - { - Node node = nodes.item(i); - short nodeType = node.getNodeType(); - if(nodeType == Node.ELEMENT_NODE) - { - sb.append(element2String(node)); - } - else if(nodeType == Node.COMMENT_NODE) - { - sb.append(comment2String(node)); - } - } - sb.append(XML_FOOTER); - return sb.toString(); - } - - private String element2String(Node node) - { - if(node == null)return ""; - StringBuffer sb = new StringBuffer(); - Element el = (Element)node; - Text text = (Text)el.getFirstChild(); - - sb.append(" "); - if(text == null) - { - sb.append(""); - } - else - { - // The node value isn't XML encoded, so be sure to escape any special characters when building up the XML - sb.append(encode(text.getNodeValue())); - } - sb.append("\n"); - return sb.toString(); - } - - private String comment2String(Node node) - { - StringBuffer sb = new StringBuffer(); - Comment com = (Comment)node; - sb.append(" \n"); - return sb.toString(); - } - - public String validate() - { - try - { - refresh(); - } - catch(SearchFormException e) - { - return e.getMessage(); - } - Element el; - try - { - el = getDocumentElement(); - } - catch(SearchFormException e) - { - return "The input XML has syntax errors: " + e.getMessage(); - } - if(!el.getTagName().equals(TAG_BIOML)) - return "Root tag name should be '" + TAG_BIOML + "'."; - NodeList notes = el.getChildNodes(); - ArrayList foundList = new ArrayList(); - for(int i = 0; i < notes.getLength(); i++) - { - Node child = notes.item(i); - if(child.getNodeType() != Node.ELEMENT_NODE) - continue; - Element elNote = (Element)child; - if(!elNote.getNodeName().equals(TAG_NOTE)) - return "Tag '" + elNote.getNodeName() + "' is not supported."; - String type = elNote.getAttribute(ATTR_TYPE); - if(type == null || type.length() == 0 || type.equals("description")) - continue; - if(!type.equals(VAL_INPUT)) - { - return "Note type '" + type + "' is not supported"; - } - String label = elNote.getAttribute(ATTR_LABEL); - if(foundList.contains(label)) - { - return "The \"" + label + "\" label appears more than once in the input XML."; - } - foundList.add(label); - } - return ""; - } - - public void removeInputParameter(String name) - { - if(name == null || name.equals("")) return; - NodeList notes = getNoteElements(); - if(notes == null) return; - for(int i = 0; i < notes.getLength(); i++) - { - Element elNote = (Element)notes.item(i); - if(isInputParameterElement(name, elNote)) - removeNode(elNote); - } - } - - private void removeNode(Node node) - { - if(node == null) return; - Element el; - try - { - el = getDocumentElement(); - } - catch(SearchFormException e) - { - return; - } - el.removeChild(node); - } - - public void setInputParameter(String name, String value) throws SearchFormException - { - if(name == null) throw new SearchFormException("Parameter name is null."); - if (value != null) - { - value = value.trim(); - } - removeInputParameter(name); - Element ip = getDocument().createElement(TAG_NOTE); - ip.setAttribute(ATTR_TYPE, VAL_INPUT); - ip.setAttribute(ATTR_LABEL,name); - ip.appendChild(getDocument().createTextNode(value)); - Element de = getDocumentElement(); - if(de == null) return; - de.appendChild(ip); - } - - /** Simple XML encoding of a string */ - private String encode(String value) - { - if(value == null) value = ""; - value = value.replace("&", "&"); - value = value.replace("<", "<"); - value = value.replace(">", ">"); - value = value.replace("\"", """); - return value; - } - - public Map getParameters() - { - NodeList notes = getNoteElements(); - if (notes == null) - { - return Collections.emptyMap(); - } - Map result = new LinkedHashMap(); - for(int i = 0; i < notes.getLength(); i++) - { - Element elNote = (Element)notes.item(i); - String value = getTrimmedTextValue(elNote.getFirstChild()); - result.put(elNote.getAttribute(ATTR_LABEL), value); - } - return result; - } - - public String getInputParameter(String name) - { - if(name == null) return ""; - NodeList notes = getNoteElements(); - if(notes == null) return null; - for(int i = 0; i < notes.getLength(); i++) - { - Element elNote = (Element)notes.item(i); - if(isInputParameterElement(name, elNote)) - { - return getTrimmedTextValue(elNote.getFirstChild()); - } - } - return ""; - } - - private String getTrimmedTextValue(Node node) - { - if (node == null) - { - return ""; - } - String result = node.getNodeValue(); - return result == null ? "" : result.trim(); - } - - private boolean isInputParameterElement(String name, Element elNote) - { - String type = elNote.getAttribute(ATTR_TYPE); - return VAL_INPUT.equals(type) && name.equals(elNote.getAttribute(ATTR_LABEL)); - } - - private NodeList getNoteElements() - { - Element el; - try - { - el = getDocumentElement(); - } - catch(SearchFormException e) - { - appendError(e.getMessage()); - return null; - } - if(el == null) return null; - return el.getElementsByTagName(TAG_NOTE); - - } - - private NodeList getAllNodes() throws SearchFormException - { - Element el = getDocumentElement(); - if(el == null) return null; - return el.getChildNodes(); - } - - private Element getDocumentElement() throws SearchFormException - { - Document xmlDoc = getDocument(); - if(xmlDoc == null) return null; - return xmlDoc.getDocumentElement(); - } - - private void refresh() throws SearchFormException - { - try - { - xmlDoc = XMLParser.parse(xmlWrapper.getText()); - } - catch(DOMParseException e) - { - throw new SearchFormException("Invalid XML. Please check your input."); - } - } - - public void writeXml() throws SearchFormException - { - xmlWrapper.setText(toXml()); - } - - private Document getDocument() throws SearchFormException - { - if( xmlDoc == null) - { - try - { - xmlDoc = XMLParser.parse(xmlWrapper.getText()); - } - catch(DOMParseException e) - { - throw new SearchFormException(e); - } - } - return xmlDoc; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/PipelineConfigCallback.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/PipelineConfigCallback.java deleted file mode 100644 index 8d8d6f46ea..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/PipelineConfigCallback.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.client; - -import org.labkey.api.gwt.client.pipeline.GWTPipelineConfig; - -/** - * User: jeckels - * Date: Feb 1, 2012 - */ -public interface PipelineConfigCallback -{ - public void setPipelineConfig(GWTPipelineConfig result); -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ProtocolComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ProtocolComposite.java deleted file mode 100644 index a10af22204..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ProtocolComposite.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Copyright (c) 2008-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.HasHorizontalAlignment; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.TextArea; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; -import org.labkey.api.gwt.client.util.StringUtils; - -import java.util.Collections; -import java.util.List; - -/** - * User: billnelson@uky.edu - * Date: Mar 25, 2008 - */ -public class ProtocolComposite extends SearchFormComposite -{ - private FlexTable instance = new FlexTable(); - private ListBox protocolListBox = new ListBox(); - private TextBox protocolNameTextBox = new TextBox(); - private TextArea protocolDescTextArea = new TextArea(); - private HTML protocolDescHtml = new HTML(); - Label textBoxLabel; - Label descriptionLabel; - private static final String NEW_PROTOCOL = ""; - private List _protocols; - - - public ProtocolComposite() - { - protocolListBox.setVisibleItemCount(1); - protocolDescHtml.setWordWrap(true); - protocolDescHtml.setStylePrimaryName("labkey-read-only"); - textBoxLabel = new Label("Name"); - descriptionLabel = new Label("Description"); - - instance.setStylePrimaryName("lk-fields-table"); - instance.setWidget(0,0,protocolListBox); - instance.getFlexCellFormatter().setColSpan(0,0,2); - - instance.setWidget(1,0,textBoxLabel); - instance.getCellFormatter().setStylePrimaryName(1,0, "labkey-form-label-nowrap"); - instance.setWidget(1,1,protocolNameTextBox); - - instance.setWidget(2,0,descriptionLabel); - instance.getCellFormatter().setStylePrimaryName(2,0, "labkey-form-label-nowrap"); - instance.getCellFormatter().setHorizontalAlignment(2,0,HasHorizontalAlignment.ALIGN_LEFT); - instance.setWidget(2,1,protocolDescTextArea); - - textBoxLabel.setStylePrimaryName(LABEL_STYLE_NAME); - descriptionLabel.setStylePrimaryName(LABEL_STYLE_NAME); - - initWidget(instance); - } - - - @Override - public Widget getLabel() - { - Label listBoxLabel = new Label("Analysis protocol"); - listBoxLabel.setStylePrimaryName(LABEL_STYLE_NAME); - return listBoxLabel; - } - - public void addChangeHandler(ChangeHandler handler) - { - protocolListBox.addChangeHandler(handler); - } - - @Override - public void setName(String name) - { - protocolListBox.setName(name); - protocolNameTextBox.setName(name + "Name"); - protocolDescTextArea.setName(name + "Description"); - } - - @Override - public String getName() - { - return protocolListBox.getName(); - } - - @Override - public void setWidth(String width) - { - instance.setWidth(width); - - protocolListBox.setWidth("100%"); - protocolNameTextBox.setWidth("100%"); - protocolDescTextArea.setWidth("100%"); - protocolDescHtml.setWidth("100%"); - instance.getColumnFormatter().setWidth(0,"2%"); - instance.getColumnFormatter().setWidth(1,"98%"); - } - - public void update(List protocolList, String defaultProtocol, String textArea) - { - setProtocolListBoxContents(protocolList, defaultProtocol); - protocolDescTextArea.setText(textArea); - } - - public void setProtocolListBoxContents(List protocols, String defaultProtocol) - { - if (protocolListBox.getItemCount() == 0 && (protocols == null || protocols.isEmpty())) - { - protocolListBox.clear(); - protocolListBox.addItem(NEW_PROTOCOL, "new"); - return; - } - - if(protocols != null && protocolListBox.getItemCount() != protocols.size() + 1) - { - _protocols = protocols; - protocolListBox.clear(); - Collections.sort(protocols); - protocols.add(0,NEW_PROTOCOL); - for (String protocol : protocols) - { - if (protocol.equals(NEW_PROTOCOL)) - { - protocolListBox.addItem(protocol, "new"); - } - else - { - protocolListBox.addItem(protocol, protocol); - } - } - } - setDefault(defaultProtocol); - } - - public void setDefault(String defaultProtocol) - { - if(defaultProtocol == null || defaultProtocol.length() == 0) - { - protocolNameTextBox.setText(""); - defaultProtocol = "new"; - } - int protocolCount = protocolListBox.getItemCount(); - boolean found = false; - for(int i = 0; i < protocolCount; i++) - { - if(protocolListBox.getValue(i).equals(defaultProtocol)) - { - found = true; - protocolListBox.setSelectedIndex(i); - break; - } - } - if(found && !defaultProtocol.equals("new")) - { - protocolNameTextBox.setText(defaultProtocol); - } - else if(!found && !defaultProtocol.equals("new")) - { - protocolListBox.setSelectedIndex(0); - protocolNameTextBox.setText(defaultProtocol); - } - else - { - protocolNameTextBox.setText(""); - } - } - - @Override - public void setReadOnly(boolean readOnly) - { - super.setReadOnly(readOnly); - - if(readOnly) - { - - protocolNameTextBox.setVisible(false); - textBoxLabel.setVisible(false); - instance.getCellFormatter().removeStyleName(1, 0, "labkey-form-label-nowrap"); - instance.remove(protocolDescTextArea); - instance.setWidget(2,1,protocolDescHtml); - if (protocolDescTextArea.getText() != null && !protocolDescTextArea.getText().trim().equals("")) - { - protocolDescHtml.setHTML(StringUtils.filter(protocolDescTextArea.getText(), true)); - } - else - { - protocolDescHtml.setHTML("" + StringUtils.filter("") + ""); - } - -// index = instance.getWidgetIndex(protocolNameTextBox); -// protocolNameHidden.setValue(protocolNameTextBox.getText()); -// protocolNameHidden.setName(protocolNameTextBox.getName()); -// if(index != -1) -// { -// instance.remove(protocolNameTextBox); -// ((VerticalPanel)labelWidget).remove(textBoxLabel); -// instance.insert(protocolNameHidden, index); -// } -// index = instance.getWidgetIndex(protocolDescTextArea); -// protocolDescHidden.setValue(protocolDescTextArea.getText()); -// protocolDescHtml.setHTML(StringUtils.filter(protocolDescTextArea.getText(), true)); -// protocolDescHidden.setName(protocolDescTextArea.getName()); -// if(index != -1) -// { -// instance.remove(protocolDescTextArea); -// instance.add(protocolDescHidden); -// instance.insert(protocolDescHtml, index); -// } - } - else - { - instance.getCellFormatter().setStylePrimaryName(1,0, "labkey-form-label-nowrap"); - //instance.getCellFormatter().setStylePrimaryName(2,0, "labkey-form-label-nowrap"); - protocolNameTextBox.setVisible(true); - instance.remove(protocolDescHtml); - instance.setWidget(2,1,protocolDescTextArea); - //protocolDescHtml.setHTML(""); - textBoxLabel.setVisible(true); - -// index = instance.getWidgetIndex(protocolNameHidden); -// if(index != -1) -// { -// instance.remove(protocolNameHidden); -// instance.insert(protocolNameTextBox, index); -// ((VerticalPanel)labelWidget).insert(textBoxLabel,index); -// } -// index = instance.getWidgetIndex(protocolDescHtml); -// if(index != -1) -// { -// instance.remove(protocolDescHidden); -// instance.remove(protocolDescHtml); -// instance.insert(protocolDescTextArea, index); -// } - } - } - - public void setVisibleLines(int lines) - { - protocolDescTextArea.setVisibleLines(lines); - } - - public String getSelectedProtocolValue() - { - try - { - return protocolListBox.getValue(protocolListBox.getSelectedIndex()); - } - catch(IndexOutOfBoundsException e) - { - return ""; - } - - } - - @Override - public String validate() - { - if(protocolNameTextBox.getText().equalsIgnoreCase("default")) - return "Sorry, default is a reserved protocol name. Please choose another."; - String selectedProtocol = getSelectedProtocolValue(); - if(selectedProtocol.equals("new")) - { - if(protocolNameTextBox.getText().equals("")) - { - return "Missing protocol name."; - } - else - { - for (int i = 0; i < protocolNameTextBox.getText().length(); i++) - { - char ch = protocolNameTextBox.getText().charAt(i); - if (!Character.isLetterOrDigit(ch) && ch != '_' && ch != ' ') - { - return "The name '" + protocolNameTextBox.getText() + "' is not a valid protocol name."; - } - } - } - } - return ""; - } - - public void newProtocol() - { - setDefault(""); - protocolDescTextArea.setText(""); - } - - /** We need to create a unique protocol name. We will append "_1", or change an existing "_X" to increment the X */ - public void copy() - { - String protocolName = protocolNameTextBox.getText(); - - if(protocolName == null || protocolName.length() == 0 ) - { - setDefault(""); - return; - } - - int index = protocolName.lastIndexOf("_"); - String prefix = protocolName + "_"; - - int versionInt = 1; - - // See if the current protocol name ends with "_X" - if( index > 0 && index != protocolName.length() - 1) - { - String versionString = protocolName.substring(index + 1); - - try - { - // See if X is a number - versionInt = Integer.parseInt(versionString) + 1; - - // Remove the X from the prefix - prefix = protocolName.substring(0, index + 1); - } - catch(NumberFormatException ignored) - { - } - } - - // Keep incrementing the number on the suffix until we have a unique name - while (_protocols != null && _protocols.contains(prefix + versionInt)) - { - versionInt++; - } - - setDefault(prefix + versionInt); - } - - public void setFocus(boolean hasFocus) - { - protocolNameTextBox.setFocus(hasFocus); - } - - @Override - public void syncFormToXml(ParamParser params) - { - - } - - @Override - public String syncXmlToForm(ParamParser params) - { - return ""; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ResidueModComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ResidueModComposite.java deleted file mode 100644 index 556ba900da..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ResidueModComposite.java +++ /dev/null @@ -1,708 +0,0 @@ -/* - * Copyright (c) 2008-2017 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.user.client.ui.*; -import org.labkey.api.gwt.client.ui.HelpPopup; -import org.labkey.api.gwt.client.ui.ImageButton; - -import java.util.*; - -/** - * User: billnelson@uky.edu - * Date: Apr 30, 2008 - */ - -/** - * ResidueModComposite - */ -public abstract class ResidueModComposite extends SearchFormComposite -{ - protected Search searchForm; - protected SimplePanel instance = new SimplePanel(); - protected TabPanel modTabPanel = new TabPanel(); - protected FlexTable staticFlexTable = new FlexTable(); - protected FlexTable dynamicFlexTable = new FlexTable(); - protected ListBox modStaticListBox = new ListBox(false); - protected ListBox modDynamicListBox = new ListBox(false); - protected ListBox staticListBox = new ListBox(); - protected ListBox dynamicListBox = new ListBox(); - protected HorizontalPanel staticPanel = new HorizontalPanel(); - protected HorizontalPanel dynamicPanel = new HorizontalPanel(); - protected AddButton addStaticButton = new AddButton(STATIC); - protected AddButton addDynamicButton = new AddButton(DYNAMIC); - protected DeleteButton deleteDynamicButton = new DeleteButton(DYNAMIC); - protected DeleteButton deleteStaticButton = new DeleteButton(STATIC); - protected NewButton newStaticButton = new NewButton(STATIC); - protected NewButton newDynamicButton = new NewButton(DYNAMIC); - protected VerticalPanel readOnlyPanel = new VerticalPanel(); - protected Label staticReadOnlyLabel = new Label(); - protected Label dynamicReadOnlyLabel = new Label(); - public static final int STATIC = 0; - public static final int DYNAMIC = 1; - private static final Map VALID_RESIDUES; - - static - { - Map residues = new LinkedHashMap(); - residues.put('A', "A - Alanine"); - residues.put('B', "B - Asparagine"); - residues.put('C', "C - Cysteine"); - residues.put('D', "D - Aspartic acid"); - residues.put('E', "E - Glutamic acid"); - residues.put('F', "F - Phenylalanine"); - residues.put('G', "G - Glycine"); - residues.put('H', "H - Histidine"); - residues.put('I', "I - Isoleucine"); - residues.put('K', "K - Lysine"); - residues.put('L', "L - Leucine"); - residues.put('M', "M - Methionine"); - residues.put('N', "N - Asparagine"); - residues.put('O', "O - Pyrrolysine"); - residues.put('P', "P - Proline"); - residues.put('Q', "Q - Glutamine"); - residues.put('R', "R - Argine"); - residues.put('S', "S - Serine"); - residues.put('T', "T - Threonine"); - residues.put('V', "V - Valine"); - residues.put('W', "W - Tryptophan"); - residues.put('X', "X - All residues"); - residues.put('Y', "Y - Tyrosine"); - residues.put('Z', "Z - Glutamine"); - residues.put(']', "C-Terminus"); - residues.put('[', "N-Terminus"); - - VALID_RESIDUES = Collections.unmodifiableMap(residues); - }; - - - - public ResidueModComposite() - { - modStaticListBox.setVisibleItemCount(3); - modStaticListBox.setWidth("250px"); - modDynamicListBox.setVisibleItemCount(3); - modDynamicListBox.setWidth("250px"); - staticListBox.setWidth("250px"); - staticListBox.setVisibleItemCount(3); - dynamicListBox.setWidth("250px"); - dynamicListBox.setVisibleItemCount(3); - staticPanel.add(staticListBox); - staticPanel.add(deleteStaticButton); - dynamicPanel.add(dynamicListBox); - dynamicPanel.add(deleteDynamicButton); - staticFlexTable.setStylePrimaryName("lk-fields-table"); - modTabPanel.add(staticFlexTable, "Fixed"); - dynamicFlexTable.setStylePrimaryName("lk-fields-table"); - modTabPanel.add(dynamicFlexTable, "Variable"); - modTabPanel.selectTab(0); - readOnlyPanel.add(staticReadOnlyLabel); - readOnlyPanel.add(dynamicReadOnlyLabel); - initWidget(instance); - } - - @Override - public void setWidth(String width) - { - StringBuffer num = new StringBuffer(); - StringBuffer type = new StringBuffer(); - StringBuffer endWidth = new StringBuffer(); - StringBuffer centerWidth = new StringBuffer(); - StringBuffer listWidth = new StringBuffer(); - for(int i = 0; i < width.length(); i++) - { - char widthChar = width.charAt(i); - if(Character.isDigit(widthChar)) - { - num.append(widthChar); - } - else - { - type.append(widthChar); - } - } - try - { - int intWidth = Integer.parseInt(num.toString()); - endWidth.append(Integer.toString((intWidth/9) * 4)); - endWidth.append(type); - centerWidth.append(Integer.toString(intWidth/9)); - centerWidth.append(type); - listWidth.append(Integer.toString(((intWidth/9) * 4)-60)); - modTabPanel.setWidth(endWidth.toString()); - staticFlexTable.getColumnFormatter().setWidth(0, endWidth.toString()); - staticFlexTable.getColumnFormatter().setWidth(1, centerWidth.toString()); - staticFlexTable.getColumnFormatter().setWidth(2, endWidth.toString()); - dynamicFlexTable.getColumnFormatter().setWidth(0, endWidth.toString()); - dynamicFlexTable.getColumnFormatter().setWidth(1, centerWidth.toString()); - dynamicFlexTable.getColumnFormatter().setWidth(2, endWidth.toString()); - modStaticListBox.setWidth(endWidth.toString()); - modDynamicListBox.setWidth(endWidth.toString()); - dynamicPanel.setWidth(endWidth.toString()); - staticPanel.setWidth(endWidth.toString()); - staticListBox.setWidth(listWidth.toString()); - dynamicListBox.setWidth(listWidth.toString()); - } - catch(NumberFormatException e) - {} - } - - @Override - public Widget getLabel() - { - Label label = new Label("Residue modifications"); - label.setStylePrimaryName(LABEL_STYLE_NAME); - HorizontalPanel panel = new HorizontalPanel(); - panel.add(label); - panel.add(new HelpPopup("Residue modifications", - "

Residue modifications, often referred to as posttranslational modifications (PTM) are the chemical modifications of a protein after its translation. Each modification will alter the mass of its associated amino acid.

" + - "

Fixed modifications are expected to be present for every amino acid of that type.

" + - "

Variable modifications may or may not be present for a given amino acid.

" + - "

'[' represents an N-terminus modification, and ']' represents a C-terminus modification.

")); - return panel; - } - - @Override - public String validate() - { - String error = validate(staticListBox, STATIC); - if(error.length()> 0) return error; - error = validate(dynamicListBox, DYNAMIC); - if(error.length()> 0) return error; - Map modMap = getStaticMods(); - ArrayList al = new ArrayList(); - - for(String sig : modMap.values()) - { - Character res = sig.charAt(sig.length()-1); - if(al.contains(res)) return "Two static residue modifications for the same residue."; - al.add(res); - } - return ""; - } - - abstract protected String validate(ListBox box, int modType); - - protected boolean isValidResidue(char res) - { - return VALID_RESIDUES.containsKey(res); - } - - public void clear() - { - staticListBox.clear(); - dynamicListBox.clear(); - } - - - - @Override - public void setName(String s) - { - //not yet - } - - @Override - public String getName() - { - return null; //Not yet - } - - public Map getStaticMods() - { - return getListBoxMap(staticListBox); - } - - public Map getDynamicMods() - { - return getListBoxMap(dynamicListBox); - } - - public void setSelectedStaticMods(Map staticMods) - { - setListBoxMods(staticMods, staticListBox); - } - - public void setSelectedDynamicMods(Map dynamicMods) - { - setListBoxMods(dynamicMods, dynamicListBox); - } - - protected void setListBoxMods(Map modMap, ListBox box) - { - if(modMap == null) return; - Set keySet = modMap.keySet(); - ArrayList sorted = new ArrayList(keySet); - Collections.sort(sorted); - box.clear(); - - for(Iterator it = sorted.iterator(); it.hasNext();) - { - String name = (String)it.next(); - String value = modMap.get(name); - box.addItem(name, value); - } - } - - protected Map getListBoxMap(ListBox box) - { - Map modMap = new HashMap(); - int modCount = box.getItemCount(); - for(int i = 0;i < modCount;i++) - { - String key = box.getItemText(i); - String value = box.getValue(i); - modMap.put(key, value); - } - return modMap; - } - - private class AddButton extends ImageButton - { - private int tabIndex; - - AddButton(int tabIndex) - { - super("Add>"); - this.tabIndex = tabIndex; - } - - @Override - public void onClick(Widget sender) - { - ListBox tabBox = getTabListBox(tabIndex); - ListBox defaultModListBox = getDefaultsListBox(tabIndex); - int modIndex = defaultModListBox.getSelectedIndex(); - if(modIndex != -1) - { - String text = defaultModListBox.getItemText(modIndex); - String value = defaultModListBox.getValue(modIndex); - if(find(text, tabBox) == -1) - { - tabBox.insertItem(text, value, 0); - } - } - String error = searchForm.syncForm2Xml(); - if(error.length() > 0) - { - searchForm.clearErrors(); - searchForm.appendError(error); - searchForm.setSearchButtonEnabled(false); - } - } - } - - public class NewButton extends ImageButton - { - private int tabIndex; - NewButton(int tabIndex) - { - super("New"); - this.tabIndex = tabIndex; - } - - @Override - public void onClick(Widget sender) - { - new NewModDialogBox(tabIndex); - } - } - - private class DeleteButton extends ImageButton - { - private int tabIndex; - DeleteButton(int tabIndex) - { - super("Remove"); - this.tabIndex = tabIndex; - } - - @Override - public void onClick(Widget sender) - { - ListBox box = getTabListBox(tabIndex); - - int boxIndex = box.getSelectedIndex(); - if(boxIndex != -1) - { - box.removeItem(boxIndex); - } - String error = searchForm.syncForm2Xml(); - if(error.length() > 0) - { - searchForm.clearErrors(); - searchForm.appendError(error); - searchForm.setSearchButtonEnabled(false); - } - else - { - searchForm.clearErrors(); - searchForm.setReadOnly(false); - } - } - } - - private class NewModDialogBox - { - private TextBox molWt = new TextBox(); - private ListBox residues = new ListBox(); - private DialogBox dialog = new DialogBox(); - private final int tabIndex; - - public NewModDialogBox(int index) - { - this.tabIndex = index; - loadResidues(residues); - dialog.setText("Create new residue modification"); - FlexTable table = new FlexTable(); - table.setStylePrimaryName("lk-fields-table"); - table.setWidget(0, 0, new Label("Residue")); - table.setWidget(0, 1, residues); - table.setWidget(1, 0, new Label("Weight")); - table.setWidget(1, 1, molWt); - table.setWidget(2, 0, new ImageButton("Enter"){ - @Override - public void onClick(Widget sender) - { - String error = ""; - String wt = molWt.getText(); - try - { - Float.parseFloat(wt); - } - catch (NumberFormatException e) - { - error = "modification mass contained an invalid mass value (" + wt + ")"; - searchForm.clearErrors(); - searchForm.appendError(error); - searchForm.setSearchButtonEnabled(false); - molWt.setText(""); - return; - } - add2List(tabIndex); - searchForm.syncForm2Xml(); - dialog.hide(); - dialog = null; - error = validate(); - if(error.length() > 0) - { - searchForm.clearErrors(); - searchForm.appendError(error); - searchForm.setSearchButtonEnabled(false); - } - else - { - searchForm.clearErrors(); - searchForm.setSearchButtonEnabled(true); - } - - } - }); - table.setWidget(2, 1, new ImageButton("Cancel") { - @Override - public void onClick(Widget sender) - { - dialog.hide(); - dialog = null; - searchForm.clearErrors(); - searchForm.setSearchButtonEnabled(true); - } - }); - dialog.setWidget(table); - dialog.center(); - molWt.setFocus(true); - } - - private void add2List(int tabIndex) - { - add2List(getTabListBox(tabIndex)); - } - - private void add2List(ListBox box) - { - String wt = molWt.getText(); - int index = residues.getSelectedIndex(); - String res = residues.getValue(index); - StringBuilder sb = new StringBuilder(); - sb.append(wt); - sb.append("@"); - sb.append(res); - String mod = sb.toString(); - String name = convertToDisplayValue(mod); - int foundIndex = find(name, box); - if(foundIndex == -1) - { - box.insertItem(name, mod, 0); - } - } - - private void loadResidues(ListBox box) - { - for (Map.Entry entry : VALID_RESIDUES.entrySet()) - { - box.addItem(entry.getValue(), entry.getKey().toString()); - } - } - } - -// private int getTabIndex() -// { -// DeckPanel deck = modTabPanel.getDeckPanel(); -// return deck.getVisibleWidget(); -// } - - private ListBox getTabListBox(int tabIndex) - { - if(tabIndex == STATIC) - return staticListBox; - else - return dynamicListBox; - } - - private ListBox getDefaultsListBox(int tabIndex) - { - if(tabIndex == STATIC) - return modStaticListBox; - else - return modDynamicListBox; - } - - protected int find(String text, ListBox box) - { - if(text == null || box == null) return -1; - for(int i = 0; i < box.getItemCount(); i++) - { - if(text.equals(box.getItemText(i))) - { - return i; - } - } - return -1; - } - - @Override - public void setReadOnly(boolean readOnly) - { - super.setReadOnly(readOnly); - if(readOnly) - { - Map modsMap = getListBoxMap(staticListBox); - Set mods = modsMap.keySet(); - StringBuilder sb = new StringBuilder(); - sb.append("Fixed Modifications: "); - int count = 0; - for(Iterator it = mods.iterator(); it.hasNext(); count++) - { - if(count > 1) sb.append(", "); - sb.append((String)it.next()); - - } - if (mods.isEmpty()) - { - sb.append(" "); - } - staticReadOnlyLabel.setText(sb.toString()); - modsMap = getListBoxMap(dynamicListBox); - mods = modsMap.keySet(); - sb.delete(0, sb.length()); - sb.append("Variable Modifications: "); - count = 0; - for(Iterator it = mods.iterator(); it.hasNext(); count++) - { - if(count > 1) sb.append(", "); - sb.append((String)it.next()); - } - if (mods.isEmpty()) - { - sb.append(" "); - } - dynamicReadOnlyLabel.setText(sb.toString()); - instance.remove(modTabPanel); - instance.setWidget(readOnlyPanel); - } - else - { - boolean removed = instance.remove(readOnlyPanel); - if(removed) - instance.add(modTabPanel); - } - } - - abstract public void update(Map mod0Map, Map mod1Map); - - abstract public Map getModMap(int modType); - - public void setStaticMods(Map mods, ParamParser params) throws SearchFormException - { - if(mods.size() == 0) - { - params.removeInputParameter(ParameterNames.STATIC_MOD); - return; - } - StringBuilder valuesString = new StringBuilder(); - for(String mod : mods.values()) - { - if(valuesString.length() > 0) - valuesString.append(","); - valuesString.append(mod); - } - params.setInputParameter(ParameterNames.STATIC_MOD, valuesString.toString()); - } - - public void setDynamicMods(Map mods, ParamParser params) throws SearchFormException - { - if(mods.size() == 0) - { - params.removeInputParameter(ParameterNames.DYNAMIC_MOD); - return; - } - StringBuilder valuesString = new StringBuilder(); - for(String mod : mods.values()) - { - if(valuesString.length() > 0) - valuesString.append(","); - valuesString.append(mod); - } - params.setInputParameter(ParameterNames.DYNAMIC_MOD, valuesString.toString()); - } - - @Override - public void syncFormToXml(ParamParser params) throws SearchFormException - { - setStaticMods(getStaticMods(), params); - setDynamicMods(getDynamicMods(), params); - } - - private Map mods2Map(String mods, Map knownMods) - { - if(knownMods == null || mods == null) return null; - Map returnMap = new HashMap(); - if(mods.length() == 0) return returnMap; - String[] modsArray = mods.split(","); - List modsList = new ArrayList(); - for (String mod : modsArray) - { - String checkMod = mod.trim(); - if (checkMod.length() > 0) - modsList.add(checkMod); - } - - for (Map.Entry knownModEntry : knownMods.entrySet()) - { - String[] sites = knownModEntry.getValue().split(","); - boolean found; - for (int i = 0; i < sites.length; i++) - { - found = false; - for (String mod : modsList) - { - if (mod.equals(sites[i])) - { - found = true; - if (i == (sites.length - 1)) - { - returnMap.put(knownModEntry.getKey(), knownModEntry.getValue()); - for (String site : sites) - { - modsList.remove(site); - } - } - break; - } - } - if (!found) break; - } - } - for (String mod : modsList) - { - returnMap.put(convertToDisplayValue(mod), mod); - } - return returnMap; - } - - private String convertToDisplayValue(String mod) - { - if (mod.length() > 2 && mod.charAt(mod.length() - 2) == '@') - { - String prefix = mod.substring(0, mod.length() - 1); - String suffix = mod.substring(mod.length() - 1).toUpperCase(); - if (VALID_RESIDUES.containsKey(suffix.charAt(0))) - { - suffix = VALID_RESIDUES.get(suffix.charAt(0)); - } - return prefix + suffix; - } - return mod; - } - - @Override - public String syncXmlToForm(ParamParser params) - { - Map staticMods = mods2Map(params.getInputParameter(ParameterNames.STATIC_MOD), getModMap(ResidueModComposite.STATIC)); - setSelectedStaticMods(staticMods); - - Map dynamicMods = mods2Map(params.getInputParameter(ParameterNames.DYNAMIC_MOD), getModMap(DYNAMIC)); - setSelectedDynamicMods(dynamicMods); - try - { - setStaticMods(staticMods, params); - setDynamicMods(dynamicMods, params); - } - catch(SearchFormException e) - { - return "Trouble adding residue modification params to input XML.\n" + e.getMessage(); - } - - return validate(); - } - - @Override - public Set getHandledParameterNames() - { - return new HashSet(Arrays.asList(ParameterNames.STATIC_MOD, ParameterNames.DYNAMIC_MOD)); - } - - protected String validateModification(String modName, String modValue, ListBox modListBox) - { - if(find(modName, modListBox) != -1) return null; - if (modValue.length() < 2) - { - return "invalid modification specified: '" + modValue + "'"; - } - if (modValue.charAt(modValue.length() - 2) != '@' && modValue.length() > 3) - { - return "modification mass contained an invalid value(" + modValue + ")."; - } - char residue = modValue.charAt(modValue.length() - 1); - if (!isValidResidue(residue)) - { - return "modification mass contained an invalid residue(" + residue + ")."; - } - String mass = modValue.substring(0, modValue.length() - 2); - float massF; - - try - { - massF = Float.parseFloat(mass); - } - catch (NumberFormatException e) - { - return "modification mass contained an invalid mass value (" + mass + ")"; - } - return null; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/Search.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/Search.java deleted file mode 100644 index bed0e77f94..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/Search.java +++ /dev/null @@ -1,990 +0,0 @@ -/* - * Copyright (c) 2008-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.CheckBox; -import com.google.gwt.user.client.ui.DialogBox; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.FormPanel; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.HasHorizontalAlignment; -import com.google.gwt.user.client.ui.HasVerticalAlignment; -import com.google.gwt.user.client.ui.Hidden; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; -import org.labkey.api.gwt.client.pipeline.GWTPipelineConfig; -import org.labkey.api.gwt.client.pipeline.PipelineGWTService; -import org.labkey.api.gwt.client.pipeline.PipelineGWTServiceAsync; -import org.labkey.api.gwt.client.ui.HelpPopup; -import org.labkey.api.gwt.client.ui.ImageButton; -import org.labkey.api.gwt.client.util.ErrorDialogAsyncCallback; -import org.labkey.api.gwt.client.util.PropertyUtil; -import org.labkey.api.gwt.client.util.ServiceUtil; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * User: billnelson@uky.edu - * Date: Jan 29, 2008 - */ -public class Search implements EntryPoint -{ - public static final String VALIDATION_FAILURE_PREFIX = "Validation failure: "; - - private static final String INPUT_WIDTH = "575px"; - private VerticalPanel subPanel = new VerticalPanel(); - private FormPanel searchFormPanel = new FormPanel(); - private FlexTable formGrid = new FlexTable(); - private Hidden pathHidden = new Hidden("path"); - private Hidden searchEngineHidden = new Hidden(); - private Hidden runSearch = new Hidden(); - private Hidden csfrHidden = new Hidden(); - private VerticalPanel messagesPanel = new VerticalPanel(); - private ProtocolComposite protocolComposite; - // Nullable - private SequenceDbComposite sequenceDbComposite; - private MzXmlComposite mzXmlComposite = new MzXmlComposite(); - // Nullable - private EnzymeComposite enzymeComposite; - // Nullable - private ResidueModComposite residueModComposite; - private TPPComposite tppComposite; - private OtherParametersComposite otherParametersComposite; - private Label searchEngineLabel = new Label(); - private Label actualSearchEngineLabel = new Label(); - private InputXmlComposite inputXmlComposite; - private HTML helpHTML = new HTML(); - private Label saveProtocolCheckBoxLabel = new Label(); - private CheckBox saveProtocolCheckBox = new CheckBox(); - private HorizontalPanel buttonPanel = new HorizontalPanel(); - private CancelButton cancelButton = new CancelButton(); - private String returnURL; - private String searchEngine; - private SearchButton searchButton = new SearchButton(); - private CopyButton copyButton = new CopyButton(); - private boolean errors = false; - private String path; // Relative path of directory containing the files - private String[] fileNames; // Names of files to be searched - - private HTML spacer; - - /** Map from subdirectory path to FASTA files */ - private Map databaseCache = new HashMap(); - private boolean sequencePathsLoaded = false; - - private PipelineGWTServiceAsync pipelineService = null; - private SearchServiceAsync service = null; - private List inputs = new ArrayList(); - - private SearchServiceAsync getSearchService() - { - if (service == null) - { - service = GWT.create(SearchService.class); - ServiceUtil.configureEndpoint(service, "searchService"); - } - return service; - } - - private PipelineGWTServiceAsync getPipelineService() - { - if (pipelineService == null) - { - pipelineService = GWT.create(PipelineGWTService.class); - ServiceUtil.configureEndpoint(pipelineService, "pipelineConfiguration", "pipeline"); - } - return pipelineService; - } - - - @Override - public void onModuleLoad() - { - spacer = new HTML(" "); - spacer.setStylePrimaryName("labkey-message-strong"); - - returnURL = PropertyUtil.getReturnURL(); - searchEngine = PropertyUtil.getServerProperty("searchEngine"); - String pipelineId = PropertyUtil.getServerProperty("pipelineId"); - SearchFormCompositeFactory compositeFactory = new SearchFormCompositeFactory(searchEngine); - sequenceDbComposite = compositeFactory.getSequenceDbComposite(this); - inputXmlComposite = compositeFactory.getInputXmlComposite(); - enzymeComposite = compositeFactory.getEnzymeComposite(); - residueModComposite = compositeFactory.getResidueModComposite(this); - tppComposite = new TPPComposite(); - protocolComposite = new ProtocolComposite(); - otherParametersComposite = new OtherParametersComposite(inputs, inputXmlComposite); - - //form - searchFormPanel.setAction(PropertyUtil.getServerProperty("targetAction")); - searchFormPanel.setMethod(FormPanel.METHOD_POST); - SearchFormHandler formHandler = new SearchFormHandler(); - searchFormPanel.addSubmitCompleteHandler(formHandler); - searchFormPanel.addSubmitHandler(formHandler); - searchFormPanel.setWidth("100%"); - - runSearch.setName("runSearch"); - runSearch.setValue("true"); - - protocolComposite.setName("protocol"); - protocolComposite.setWidth(INPUT_WIDTH); - protocolComposite.setVisibleLines(4); - - searchEngineLabel.setText("Search engine"); - searchEngineLabel.setStylePrimaryName("labkey-form-label-nowrap"); - actualSearchEngineLabel.setStylePrimaryName("labkey-read-only"); - actualSearchEngineLabel.setText(searchEngine); - - if (sequenceDbComposite != null) - { - sequenceDbComposite.setName("sequenceDB"); - sequenceDbComposite.setWidth(INPUT_WIDTH); - sequenceDbComposite.setVisibleItemCount(4); - } - - if (enzymeComposite != null) - { - enzymeComposite.setWidth(INPUT_WIDTH); - } - - if (residueModComposite != null) - { - residueModComposite.setWidth(INPUT_WIDTH); - } - - inputXmlComposite.setName("configureXml"); - inputXmlComposite.setWidth("100%"); - - helpHTML.setHTML("For detailed explanations of all available input parameters, see the " + searchEngine + " Documentation."); - - saveProtocolCheckBoxLabel.setText("Save protocol"); - saveProtocolCheckBoxLabel.setStylePrimaryName("labkey-form-label-nowrap"); - saveProtocolCheckBox.setName("saveProtocol"); - saveProtocolCheckBox.setValue(Boolean.valueOf(PropertyUtil.getServerProperty("saveProtocol"))); - buttonPanel.setSpacing(5); - buttonPanel.add(searchButton); - buttonPanel.add(cancelButton); - - loadSubPanel(); - searchFormPanel.add(subPanel); - - //hidden fields - path = PropertyUtil.getServerProperty("path"); - pathHidden.setValue(path); - searchEngineHidden.setName("searchEngine"); - searchEngineHidden.setValue(searchEngine); - - csfrHidden.setName("X-LABKEY-CSRF"); - csfrHidden.setValue(ServiceUtil.getCsrfToken()); - - fileNames = PropertyUtil.getServerProperty("file").split("/"); - for (String fileName : fileNames) - { - subPanel.add(new Hidden("file", fileName)); - } - - loading(); - getSearchService().getSearchServiceResult(searchEngine, path, fileNames, new SearchServiceAsyncCallback()); - - getPipelineService().getLocationOptions(pipelineId, new ErrorDialogAsyncCallback() - { - @Override - public void onSuccess(GWTPipelineConfig result) - { - for (SearchFormComposite input : inputs) - { - if (input instanceof PipelineConfigCallback) - { - ((PipelineConfigCallback) input).setPipelineConfig(result); - } - } - } - }); - - protocolComposite.addChangeHandler(new ProtocolChangeListener()); - - if (sequenceDbComposite != null) - { - sequenceDbComposite.addChangeListener(new SequenceDbChangeListener()); - sequenceDbComposite.addRefreshClickHandler(new RefreshSequenceDbPathsClickListener()); - sequenceDbComposite.addClickHandler(new SequenceDbClickListener()); - sequenceDbComposite.addTaxonomyChangeHandler(new TaxonomyChangeListener()); - } - - if (enzymeComposite != null) - { - enzymeComposite.addChangeListener(new EnzymeChangeListener()); - } - tppComposite.addChangeListener(new LocationChangeListener()); - otherParametersComposite.addChangeListener(new LocationChangeListener()); - - inputXmlComposite.addChangeListener(new InputXmlChangeListener()); - - - RootPanel panel = RootPanel.get("org.labkey.ms2.pipeline.Search-Root"); - - panel.add(searchFormPanel); - setReadOnly(true); - } - - public void setReadOnly(boolean readOnly) - { - setReadOnly(readOnly, false); - } - - private void setReadOnly(boolean readOnly, boolean force) - { - protocolComposite.setReadOnly(readOnly); - for (SearchFormComposite input : inputs) - { - input.setReadOnly(readOnly); - } - inputXmlComposite.setReadOnly(readOnly); - saveProtocolCheckBox.setEnabled(!readOnly); - if(protocolComposite.getSelectedProtocolValue().equals("new")) - buttonPanel.remove(copyButton); - else - buttonPanel.insert(copyButton, 1); - if (mzXmlComposite.hasRun() && !protocolComposite.getSelectedProtocolValue().equals("new")) - searchButton.setText("Retry"); - else - searchButton.setText("Search"); - if(hasErrors() || !mzXmlComposite.hasWork()) - { - if(force) searchButton.setEnabled(true); - else searchButton.setEnabled(false); - } - else - { - searchButton.setEnabled(true); - } - } - - private void newProtocol() - { - protocolComposite.newProtocol(); - inputXmlComposite.setDefault(); - changeProtocol(); - } - - private void copyAndEdit() - { - protocolComposite.copy(); - changeProtocol(); - - } - - private void changeProtocol() - { - if (residueModComposite != null) - { - residueModComposite.clear(); - } - mzXmlComposite.clearStatus(); - if (sequenceDbComposite != null) - { - sequenceDbComposite.setLoading(true); - sequenceDbComposite.setEnabled(false, false); - getSearchService().getSequenceDbs(sequenceDbComposite.getSelectedDb(), searchEngine, false, - new SequenceDbServiceCallback()); - } - buttonPanel.remove(copyButton); - protocolComposite.setFocus(true); - String error = syncXml2Form(); - if(error.length() > 0) - { - clearErrors(); - appendError(error); - setReadOnly(false); - setSearchButtonEnabled(false); - } - else - { - clearErrors(); - setReadOnly(false); - } - } - - private void cancelForm() - { - if (null == returnURL || returnURL.length() == 0) - History.back(); - else - Window.Location.replace(returnURL); - } - - private void loadSubPanel() - { - subPanel.add(pathHidden); - subPanel.add(searchEngineHidden); - subPanel.add(csfrHidden); - subPanel.add(runSearch); - subPanel.add(messagesPanel); - subPanel.add(new Label("An MS2 search protocol is defined by a set of options for the search engine and a set of protein databases to search.")); - subPanel.add(new Label("Choose an existing protocol or define a new one.")); - subPanel.setWidth("100%"); - - inputs.add(mzXmlComposite); - if (sequenceDbComposite != null) - { - inputs.add(sequenceDbComposite); - } - if (enzymeComposite != null) - { - inputs.add(enzymeComposite); - } - if (residueModComposite != null) - { - inputs.add(residueModComposite); - } - inputs.add(tppComposite); - inputs.add(otherParametersComposite); - - int row = 0; - formGrid.setStylePrimaryName("lk-fields-table"); - formGrid.setWidget(row, 0, protocolComposite.getLabel()); - formGrid.setWidget(row++, 1, protocolComposite); - formGrid.setWidget(row, 0, searchEngineLabel); - formGrid.setWidget(row++, 1, actualSearchEngineLabel); - for (SearchFormComposite input : inputs) - { - formGrid.setWidget(row, 0, input.getLabel()); - formGrid.setWidget(row, 1, input); - input.configureCompositeRow(formGrid, row++); - } - formGrid.setWidget(row, 0, inputXmlComposite.getLabel()); - formGrid.setWidget(row++, 1, inputXmlComposite); - - HorizontalPanel saveLabelPanel = new HorizontalPanel(); - saveLabelPanel.add(saveProtocolCheckBoxLabel); - saveLabelPanel.add(new HelpPopup("Save protocol", "Whether or not this set of analysis parameters should be saved to use for future searches.")); - - formGrid.setWidget(row, 0, saveLabelPanel); - formGrid.setWidget(row++, 1, saveProtocolCheckBox); - formGrid.getColumnFormatter().setWidth(1,"100%"); - - for(int i = 0; i< formGrid.getRowCount(); i++) - { - formGrid.getCellFormatter().setStylePrimaryName(i,0, "labkey-form-label-nowrap"); - formGrid.getCellFormatter().setVerticalAlignment(i,0,HasVerticalAlignment.ALIGN_TOP); - formGrid.getCellFormatter().setVerticalAlignment(i,1,HasVerticalAlignment.ALIGN_TOP); - } - - subPanel.add(formGrid); - subPanel.add(buttonPanel); - subPanel.add(helpHTML); - } - - public void appendError(String error) - { - if(error == null || error.trim().length() == 0) - { - return; - } - setErrors(true); - new ErrorDialogBox(error); - } - - private void appendMessage(String message) - { - if(message == null || message.trim().length() == 0) - { - return; - } - Label label = new Label(message); - label.setStylePrimaryName("labkey-message-strong"); - if (messagesPanel.getWidgetCount() == 1 && messagesPanel.getWidget(0) == spacer) - { - messagesPanel.remove(spacer); - } - messagesPanel.add(label); - } - - public void clearErrors() - { - setErrors(false); - messagesPanel.clear(); - messagesPanel.add(spacer); - } - - private void setError(String error) - { - clearErrors(); - appendError(error); - } - - private void setDisplay(String text) - { - clearErrors(); - appendMessage(text); - } - - private boolean hasErrors() - { - return errors; - } - - private void setErrors(boolean errors) - { - this.errors = errors; - } - - - private void loading() - { - setDisplay("LOADING..."); - } - - public String syncForm2Xml() - { - try - { - for (SearchFormComposite input : inputs) - { - input.syncFormToXml(inputXmlComposite.params); - } - inputXmlComposite.writeXml(); - } - catch(SearchFormException e) - { - return "Trouble adding selected parameter to input XML.\n" + e.getMessage(); - } - if (residueModComposite != null) - { - return residueModComposite.validate(); - } - return ""; - } - - public String syncXml2Form() - { - StringBuilder error = new StringBuilder(); - for (SearchFormComposite input : inputs) - { - error.append(input.syncXmlToForm(inputXmlComposite.params)); - } - try - { - inputXmlComposite.writeXml(); - } - catch(SearchFormException e) - { - error.append("Trouble writing XML: ").append(e.getMessage()); - } - - return error.toString(); - } - - public void setSearchButtonEnabled(boolean enabled) - { - searchButton.setEnabled(enabled); - } - - public void getSequenceDbs(String sequenceDb) - { - getSearchService().getSequenceDbs(sequenceDb, searchEngine, false, new SequenceDbServiceCallback()); - } - - private class SearchButton extends ImageButton - { - SearchButton() - { - super("Search"); - } - - @Override - public void onClick(Widget sender) - { - clearErrors(); - boolean foundError = false; - for (SearchFormComposite input : inputs) - { - String validation = input.validate(); - if (validation != null && !validation.isEmpty()) - { - appendError(validation); - foundError = true; - } - } - if (!foundError) - { - searchFormPanel.submit(); - } - } - -// public void setEnabled(boolean enabled) -// { -// super.setEnabled(enabled); -// this.enabled = enabled; -// } -// -// public boolean isEnabled() -// { -// return enabled; -// } - } - - private class CopyButton extends ImageButton - { - CopyButton() - { - super("Copy & Edit"); - } - - @Override - public void onClick(Widget sender) - { - copyAndEdit(); - } - } - - private class CancelButton extends ImageButton - { - CancelButton() - { - super("Cancel"); - } - - @Override - public void onClick(Widget sender) - { - cancelForm(); - } - } - - public static class ErrorDialogBox - { - private DialogBox dialog = new DialogBox(); - private final String error; - - public ErrorDialogBox(String errorString) - { - error = errorString; - Label label = new Label(error); - label.setStylePrimaryName("labkey-error"); - dialog.setText("Error"); - VerticalPanel vPanel = new VerticalPanel(); - vPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER ); - vPanel.add(label); - ImageButton okButton = new ImageButton("OK") { - @Override - public void onClick(Widget sender) - { - dialog.hide(); - dialog = null; - } - }; - vPanel.add(okButton); - dialog.setWidget(vPanel); - dialog.center(); - okButton.setFocus(true); - } - } - private class SearchFormHandler implements FormPanel.SubmitCompleteHandler, FormPanel.SubmitHandler - { - @Override - public void onSubmit(FormPanel.SubmitEvent event) - { - clearErrors(); - appendError(protocolComposite.validate()); - if (sequenceDbComposite != null) - { - appendError(sequenceDbComposite.validate()); - } - appendError(tppComposite.validate()); - if (hasErrors()) - { - event.cancel(); - } - } - - @Override - public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) - { - String results = event.getResults(); - if(results == null) - { - appendError("The web server is not responding."); - } - else if(results.contains("SUCCESS=")) - { - String destination = results.substring(results.indexOf("SUCCESS=") + 8); - destination = destination.trim(); - if(destination.length() == 0) - { - appendError("The submit did not return a destination."); - setReadOnly(false, true); - } - Window.Location.replace(destination); - appendMessage("Navigating to " + destination); - - } - else if(results.contains("ERROR=")) - { - String errorString = results.substring(results.indexOf("ERROR=") + 6); - errorString = errorString.trim(); - appendError(errorString); - if (errorString.startsWith(VALIDATION_FAILURE_PREFIX) && Boolean.TRUE.equals(saveProtocolCheckBox.getValue())) - { - // The server didn't like our protocol definition. Refresh so we get a read-only view of it. - getSearchService().getSearchServiceResult(searchEngine, path, fileNames, new SearchServiceAsyncCallback()); - } - else - { - setReadOnly(false, true); - } - } - else if(results.contains("User does not have permission")) - { - cancelForm(); - } - else - { - appendError("Unexpected response from server: " + results); - setReadOnly(false); - } - } - } - - private class SequenceDbServiceCallback extends ErrorDialogAsyncCallback - { - @Override - public void reportFailure(String message, Throwable caught) - { - if(caught.getMessage().contains("User does not have permission")) - { - cancelForm(); - } - else if(!(caught.getClass().getName().equals("com.google.gwt.user.client.rpc.InvocationException") - && caught.getMessage().length() == 0)) - { - super.reportFailure(message, caught); - } - } - - @Override - public void onSuccess(GWTSearchServiceResult gwtResult) - { - databaseCache.put(gwtResult.getCurrentPath(), gwtResult); - updateDatabases(gwtResult); - } - } - - private void updateDatabases(GWTSearchServiceResult gwtResult) - { - String selectedDb = sequenceDbComposite.getSelectedDbPath(); - if (sequencePathsLoaded && selectedDb != null && !gwtResult.getCurrentPath().equals(selectedDb)) - { - // This is a listing for a directory that we're not trying to render anymore. The user has probably - // changed the selected path again before the response from the first request finished. - return; - } - - if (sequenceDbComposite.isReadOnly()) - { - // The user probably messed up the XML and we're not showing the database selection UI, so don't try to do anything - return; - } - - sequenceDbComposite.setLoading(false); - List sequenceDbs = gwtResult.getSequenceDBs(); - List sequenceDbPaths = gwtResult.getSequenceDbPaths(); - - sequenceDbComposite.setSequenceDbPathListBoxContents(sequenceDbPaths, - gwtResult.getCurrentPath()); - - sequencePathsLoaded = true; - - if(sequenceDbs != null) - { - sequenceDbComposite.setSequenceDbsListBoxContents(sequenceDbs, gwtResult.getDefaultSequenceDb()); - } - appendError(gwtResult.getErrors()); - sequenceDbComposite.selectDefaultDb(gwtResult.getDefaultSequenceDb()); - - // Check to be sure that all of the FASTAs referenced by the saved protocol are still available - // (and already selected) in the FASTA list - Set inputDbs = new HashSet(Arrays.asList(inputXmlComposite.params.getInputParameter(ParameterNames.SEQUENCE_DB).split(";"))); - Set listBoxDbs = new HashSet(Arrays.asList(sequenceDbComposite.getSelectedDb().split(";"))); - - if(!inputDbs.isEmpty() && !inputDbs.equals(listBoxDbs)) - { - appendError("The database entered for the input XML label \"" + ParameterNames.SEQUENCE_DB + "\" cannot be found" - + " at this FASTA root. " + inputDbs + " vs " + listBoxDbs); - inputXmlComposite.params.removeInputParameter(ParameterNames.SEQUENCE_DB); - try - { - inputXmlComposite.writeXml(); - } - catch(SearchFormException ignored) {} - sequenceDbComposite.setEnabled(true, true); - return; - } - appendError(syncForm2Xml()); - sequenceDbComposite.setEnabled(true, true); - } - - private class ProtocolServiceAsyncCallback extends ErrorDialogAsyncCallback - { - @Override - public void onSuccess(GWTSearchServiceResult gwtResult) - { - clearErrors(); - appendError(gwtResult.getErrors()); - List protocols = gwtResult.getProtocols(); - String defaultProtocol = gwtResult.getSelectedProtocol(); - String protocolDescription = gwtResult.getProtocolDescription(); - protocolComposite.update(protocols, defaultProtocol, protocolDescription); - mzXmlComposite.update(gwtResult.getFileInputNames(), gwtResult.getFileInputStatus(), - gwtResult.isActiveJobs()); - appendError(inputXmlComposite.update(gwtResult.getProtocolXml())); - appendError(syncXml2Form()); - String defaultDb = gwtResult.getDefaultSequenceDb(); - if (sequenceDbComposite != null) - { - sequenceDbComposite.setSequenceDbsListBoxContents(null, defaultDb); - } - if(defaultProtocol == null || defaultDb.equals("")) - setReadOnly(false); - else - setReadOnly(true); - } - } - - private class SearchServiceAsyncCallback extends ErrorDialogAsyncCallback - { - @Override - public void onSuccess(GWTSearchServiceResult gwtResult) - { - setError(PropertyUtil.getServerProperty("errors")); - List sequenceDbs = gwtResult.getSequenceDBs(); - List sequenceDbPaths = gwtResult.getSequenceDbPaths(); - String defaultDb = gwtResult.getDefaultSequenceDb(); - List taxonomy = gwtResult.getMascotTaxonomyList(); - if (sequenceDbComposite != null) - { - sequenceDbComposite.update(sequenceDbs, sequenceDbPaths, defaultDb, taxonomy); - } - List protocols = gwtResult.getProtocols(); - String defaultProtocol = gwtResult.getSelectedProtocol(); - String protocolDescription = gwtResult.getProtocolDescription(); - protocolComposite.update(protocols, defaultProtocol, protocolDescription); - mzXmlComposite.update(gwtResult.getFileInputNames(), gwtResult.getFileInputStatus(), - gwtResult.isActiveJobs()); - if (enzymeComposite != null) - { - enzymeComposite.update(gwtResult.getEnzymeMap()); - } - if (residueModComposite != null) - { - residueModComposite.update(gwtResult.getMod0Map(), gwtResult.getMod1Map()); - } - appendError(inputXmlComposite.update(gwtResult.getProtocolXml())); - appendError(syncXml2Form()); - appendError(gwtResult.getErrors()); - if(defaultProtocol == null || defaultProtocol.equals("")) - setReadOnly(false); - else - setReadOnly(true); - } - } - - private class SequenceDbChangeListener implements ChangeHandler - { - @Override - public void onChange(ChangeEvent e) - { - String dbDirectory = sequenceDbComposite.getSelectedDbPath(); - sequenceDbComposite.setLoading(true); - sequenceDbComposite.setEnabled(true, false); - inputXmlComposite.params.removeInputParameter(ParameterNames.SEQUENCE_DB); - - if (databaseCache.containsKey(dbDirectory)) - { - final GWTSearchServiceResult gwtResult = databaseCache.get(dbDirectory); - if (gwtResult != null) - { - updateDatabases(gwtResult); - } - } - else - { - service.getSequenceDbs(dbDirectory, searchEngine, false, new SequenceDbServiceCallback()); - - // Stick in a null so that we don't request it again - databaseCache.put(dbDirectory, null); - } - } - } - - private class ProtocolChangeListener implements ChangeHandler - { - @Override - public void onChange(ChangeEvent e) - { - clearErrors(); - String protocolName = protocolComposite.getSelectedProtocolValue(); - if(protocolName.equals("new")) - { - newProtocol(); - return; - } - loading(); - service.getProtocol(searchEngine, protocolName, path, fileNames, new ProtocolServiceAsyncCallback()); - } - } - - private class SequenceDbClickListener implements ClickHandler - { - @Override - public void onClick(ClickEvent e) - { - String db = sequenceDbComposite.getSelectedDb(); - if(db.length() > 0 && !db.equals("None found.")) - { - clearErrors(); - inputXmlComposite.params.removeInputParameter(ParameterNames.SEQUENCE_DB); - String error = syncForm2Xml(); - if(error.length() > 0 ) - { - appendError(error); - searchButton.setEnabled(false); - } - else - { - setReadOnly(false); - } - } - } - } - - private class TaxonomyChangeListener implements ChangeHandler - { - @Override - public void onChange(ChangeEvent e) - { - String tax = sequenceDbComposite.getSelectedTaxonomy(); - if(tax.length() > 0) - { - inputXmlComposite.params.removeInputParameter(ParameterNames.TAXONOMY); - clearErrors(); - String error = syncForm2Xml(); - if(error.length() > 0 ) - { - appendError(error); - searchButton.setEnabled(false); - } - else - { - setReadOnly(false); - } - } - } - } - - private class LocationChangeListener implements ChangeHandler - { - @Override - public void onChange(ChangeEvent event) - { - syncForm2Xml(); - } - } - - private class EnzymeChangeListener implements ChangeHandler - { - @Override - public void onChange(ChangeEvent e) - { - String enz = enzymeComposite.getSelectedEnzyme(); - if(enz.length() > 0) - { - inputXmlComposite.params.removeInputParameter(ParameterNames.ENZYME); - clearErrors(); - String error = syncForm2Xml(); - if(error.length() > 0 ) - { - appendError(syncForm2Xml()); - searchButton.setEnabled(false); - } - else - { - setReadOnly(false); - } - } - } - } - - private class RefreshSequenceDbPathsClickListener implements ClickHandler - { - @Override - public void onClick(ClickEvent e) - { - databaseCache.clear(); - sequencePathsLoaded = false; - String defaultSequenceDb = inputXmlComposite.params.getInputParameter(ParameterNames.SEQUENCE_DB); - service.getSequenceDbs(defaultSequenceDb, searchEngine, true, new SequenceDbServiceCallback()); - sequenceDbComposite.setLoading(true); - sequenceDbComposite.setEnabled(false, false); - } - } - - private class InputXmlChangeListener implements ChangeHandler - { - @Override - public void onChange(ChangeEvent e) - { - String error = inputXmlComposite.validate(); - if(error.length() > 0) - { - clearErrors(); - appendError(error); - setReadOnly(true); - inputXmlComposite.setReadOnly(false); - return; - } - error = syncXml2Form(); - if(error.length() > 0) - { - clearErrors(); - appendError(error); - searchButton.setEnabled(false); - return; - } - clearErrors(); - setReadOnly(false); - } - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormComposite.java deleted file mode 100644 index 29f1434ec1..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormComposite.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2008-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.HasName; -import com.google.gwt.user.client.ui.Widget; - -import java.util.Collections; -import java.util.Set; - -/** - * User: billnelson@uky.edu - * Date: Mar 25, 2008 - */ -public abstract class SearchFormComposite extends Composite implements HasName -{ - public static final String LABEL_STYLE_NAME = "labkey-form-label"; - - protected boolean readOnly; - - protected int _parentTableRow; - protected FlexTable _parentTable; - - public boolean isReadOnly() - { - return readOnly; - } - - public void setReadOnly(boolean readOnly) - { - this.readOnly = readOnly; - } - - @Override - abstract public void setWidth(String width); - - abstract public Widget getLabel(); - - abstract public String validate(); - - abstract public void syncFormToXml(ParamParser params) throws SearchFormException; - - abstract public String syncXmlToForm(ParamParser params); - - public void configureCompositeRow(FlexTable table, int row) - { - _parentTable = table; - _parentTableRow = row; - } - - public boolean isHandledParameterName(String name) - { - return getHandledParameterNames().contains(name); - } - - public Set getHandledParameterNames() - { - return Collections.emptySet(); - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormCompositeFactory.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormCompositeFactory.java deleted file mode 100644 index 10ee97774b..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormCompositeFactory.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2008-2015 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import org.labkey.ms2.pipeline.client.mascot.MascotEnzymeComposite; -import org.labkey.ms2.pipeline.client.mascot.MascotResidueModComposite; -import org.labkey.ms2.pipeline.client.mascot.MascotSequenceDbComposite; -import org.labkey.ms2.pipeline.client.sequest.SequestResidueModComposite; -import org.labkey.ms2.pipeline.client.sequest.SimpleSequenceDbComposite; -import org.labkey.ms2.pipeline.client.tandem.XtandemInputXmlComposite; -import org.labkey.ms2.pipeline.client.tandem.XtandemResidueModComposite; -import org.labkey.ms2.pipeline.client.tandem.XtandemSequenceDbComposite; - -/** - * User: billnelson@uky.edu - * Date: Apr 17, 2008 - */ - -/** - * SearchFormCompositeFactory - */ -public class SearchFormCompositeFactory -{ - private static final String XTANDEM = "X! Tandem"; - private static final String MASCOT = "Mascot"; - private static final String FRACTION_ROLLUP = "FractionRollup"; - private static final String SEQUEST = "Sequest"; - private static final String COMET = "Comet"; - private String searchEngine; - - public SearchFormCompositeFactory(String searchEngine) - { - this.searchEngine = searchEngine; - } - - /** Nullable */ - public SequenceDbComposite getSequenceDbComposite(Search search) - { - if(searchEngine.equals(XTANDEM)) - return new XtandemSequenceDbComposite(search); - else if(searchEngine.equals(MASCOT)) - return new MascotSequenceDbComposite(search); - else if (searchEngine.equals(FRACTION_ROLLUP)) - return null; - return new SimpleSequenceDbComposite(search); - } - - public InputXmlComposite getInputXmlComposite() - { - if(searchEngine.equals(XTANDEM)) - return new XtandemInputXmlComposite(); - else if(searchEngine.equals(MASCOT)) - { - ParameterNames.ENZYME = "mascot, enzyme"; - ParameterNames.STATIC_MOD = "mascot, fixed modifications"; - ParameterNames.DYNAMIC_MOD = "mascot, variable modifications"; - return new GeneralInputXmlComposite("Mascot XML", "pipelineMascot"); - } - else if(searchEngine.equals(SEQUEST)) - return new GeneralInputXmlComposite("Sequest XML", "pipelineSequest"); - else if(searchEngine.equals(COMET)) - return new GeneralInputXmlComposite("Comet XML", "pipelineComet"); - else if(searchEngine.equals(FRACTION_ROLLUP)) - return new GeneralInputXmlComposite("Fraction rollup XML", "pipelineFractionRollup"); - else - return null; - } - - /** Nullable */ - public EnzymeComposite getEnzymeComposite() - { - if(searchEngine.equals(MASCOT)) - return new MascotEnzymeComposite(); - else if (searchEngine.equals(FRACTION_ROLLUP)) - return null; - return new EnzymeComposite(); - } - - /** Nullable */ - public ResidueModComposite getResidueModComposite(Search searchForm) - { - if(searchEngine.equals(XTANDEM)) - return new XtandemResidueModComposite(searchForm); - else if(searchEngine.equals(MASCOT)) - return new MascotResidueModComposite(searchForm); - else if(searchEngine.equals(SEQUEST) || searchEngine.equals(COMET)) - return new SequestResidueModComposite(searchForm); - else - return null; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormException.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormException.java deleted file mode 100644 index b56523ae4d..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchFormException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -/** - * User: billnelson@uky.edu - * Date: Apr 21, 2008 - */ - -/** - * SearchFormException - */ -public class SearchFormException extends Exception -{ - public SearchFormException() - { - } - - public SearchFormException(String s) - { - super(s); - } - - public SearchFormException(String s, Throwable throwable) - { - super(s, throwable); - } - - public SearchFormException(Throwable throwable) - { - super(throwable); - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchService.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchService.java deleted file mode 100644 index cb59f6c50e..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.user.client.rpc.RemoteService; -import com.google.gwt.user.client.rpc.SerializableException; -import org.labkey.ms2.pipeline.client.GWTSearchServiceResult; - - -/** - * User: billnelson@uky.edu - * Date: Jan 29, 2008 - */ -public interface SearchService extends RemoteService -{ - public GWTSearchServiceResult getSearchServiceResult(String searchEngine, - String path, String[] fileNames); - - public GWTSearchServiceResult getSequenceDbs(String defaultDb, String searchEngine, boolean refresh) - ; - - public GWTSearchServiceResult getProtocol(String searchEngine, String protocolName, String path, String[] fileNames) - ; - - public GWTSearchServiceResult getMascotTaxonomy(String searchEngine); - - public GWTSearchServiceResult getEnzymes(String searchEngine); -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchServiceAsync.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchServiceAsync.java deleted file mode 100644 index 7cf1cd8286..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SearchServiceAsync.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2008-2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.rpc.SerializableException; - -/** - * User: billnelson@uky.edu - * Date: Jan 29, 2008 - */ -public interface SearchServiceAsync -{ - void getSearchServiceResult(String searchEngine, String path, String[] fileNames, - AsyncCallback async); - void getSequenceDbs(String defaultDb, String searchEngine, boolean refresh, AsyncCallback async); - - void getProtocol(String searchEngine, String protocolName, String path, String[] fileNames, AsyncCallback async); - - void getMascotTaxonomy(String searchEngine, AsyncCallback async); - - void getEnzymes(String searchEngine, AsyncCallback async); -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SequenceDbComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SequenceDbComposite.java deleted file mode 100644 index 51903ffafd..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/SequenceDbComposite.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Copyright (c) 2008-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.*; - -import java.util.*; - -import org.labkey.api.gwt.client.ui.HelpPopup; -import org.labkey.api.gwt.client.ui.ImageButton; - -/** - * User: billnelson@uky.edu - * Date: Mar 13, 2008 - */ - -public abstract class SequenceDbComposite extends SearchFormComposite -{ - protected final VerticalPanel instance = new VerticalPanel(); - protected final ListBox sequenceDbPathListBox = new ListBox(); - protected final ListBox sequenceDbListBox; - protected final Hidden sequenceDbHidden = new Hidden(); - protected final Hidden sequenceDbPathHidden = new Hidden(); - protected final Label sequenceDbLabel = new Label(); - protected final HorizontalPanel dirPanel = new HorizontalPanel(); - protected final Label statusLabel = new Label(); - protected final RefreshButton refreshButton = new RefreshButton(); - protected final HorizontalPanel refreshPanel = new HorizontalPanel(); - protected boolean hasDirectories; - protected boolean foundDefaultDb; - public static final String DB_DIR_ROOT = ""; - private final Search _search; - - protected SequenceDbComposite(Search search, boolean allowMultipleFASTAs) - { - _search = search; - sequenceDbListBox = new ListBox(allowMultipleFASTAs); - sequenceDbPathListBox.setVisibleItemCount(1); - sequenceDbLabel.setStylePrimaryName("labkey-read-only"); - dirPanel.add(sequenceDbPathListBox); - dirPanel.add(statusLabel); - dirPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); - statusLabel.setWidth("100px"); - statusLabel.setStylePrimaryName("labkey-message-strong"); - dirPanel.setSpacing(3); - instance.add(dirPanel); - instance.add(sequenceDbListBox); - initWidget(instance); - } - - public void update(List files, List directories, String defaultDb, List taxonomy) - { - setSequenceDbPathListBoxContents(directories,defaultDb); - setSequenceDbsListBoxContents(files,defaultDb); - } - - public void setSequenceDbPathListBoxContents(List paths, String defaultDb) - { - String defaultPath; - if(defaultDb == null) - { - defaultPath = ""; - } - else - { - defaultPath = defaultDb.substring(0, defaultDb.lastIndexOf('/') + 1); - } - sequenceDbPathListBox.clear(); - if (paths == null) - { - paths = new ArrayList(); - } - hasDirectories = !paths.isEmpty(); - - sequenceDbPathListBox.addItem(DB_DIR_ROOT, "/"); - Collections.sort(paths, String.CASE_INSENSITIVE_ORDER); - for (String dirName : paths) - { - if (dirName == null || dirName.equals("")) - continue; - sequenceDbPathListBox.addItem(dirName, dirName); - } - int pathCount = sequenceDbPathListBox.getItemCount(); - for(int i = 0; i < pathCount; i++) - { - String dir = sequenceDbPathListBox.getValue(i); - if(dir.equals(defaultPath)) - { - sequenceDbPathListBox.setSelectedIndex(i); - break; - } - } - } - - public void setSequenceDbsListBoxContents(List files, String defaultDb) - { - if(defaultDb == null) defaultDb = ""; - if(files == null || files.size() == 0) - { - files = new ArrayList(); - int index = defaultDb.lastIndexOf("/"); - if(index != -1) - { - files.add(defaultDb.substring(index + 1)); - } - else - { - files.add(defaultDb); - } - } - sequenceDbListBox.clear(); - if(files.isEmpty()) return; - Collections.sort(files, String.CASE_INSENSITIVE_ORDER); - String path; - for (String fileName : files) - { - path = ""; - if (fileName == null || fileName.equals("")) - continue; - int index = defaultDb.lastIndexOf("/"); - if (index != -1) - { - path = defaultDb.substring(0, index + 1); - if (path.equals("/")) path = ""; - } - sequenceDbListBox.addItem(fileName, path + fileName); - } - setDefault(defaultDb); - } - - public boolean setDefault(String defaultDb) - { - String path = "/"; - if(defaultDb == null || defaultDb.length() == 0) - { - setFoundDefaultDb(false); - return true; - } - int index = defaultDb.lastIndexOf('/'); - if(index != -1) - { - path = defaultDb.substring(0, defaultDb.lastIndexOf('/') + 1); - } - - int pathItemsCount = sequenceDbPathListBox.getItemCount(); - if(hasDirectories) - { - boolean wrongDir = true; - for(int i = 0; i < pathItemsCount; i++) - { - String listPath = sequenceDbPathListBox.getValue(i); - boolean isSelected = sequenceDbPathListBox.isItemSelected(i); - if(listPath.equals(path) && isSelected) - { - wrongDir = false; - selectDefaultDb(defaultDb); - break; - } - } - if( wrongDir) - { - setFoundDefaultDb(false); - } - } - selectDefaultDb(defaultDb); - return true; - } - - public void selectDefaultDb(String name) - { - setFoundDefaultDb(false); - if(name == null|| name.length() == 0) return; - - Set defaultDbs = new HashSet(); - - for (String defaultDb : Arrays.asList(name.split(";"))) - { - if(defaultDb.indexOf("/") == 0) - { - defaultDb = defaultDb.substring(1); - } - defaultDbs.add(defaultDb); - } - - int dbItemsCount = sequenceDbListBox.getItemCount(); - for(int i = 0; i < dbItemsCount; i++) - { - if(defaultDbs.contains(sequenceDbListBox.getValue(i))) - { - sequenceDbListBox.setItemSelected(i, true); - setFoundDefaultDb(true); - } - else - { - sequenceDbListBox.setItemSelected(i, false); - } - } - } - - public boolean foundDefaultDb() - { - return foundDefaultDb; - } - - public void setFoundDefaultDb(boolean found) - { - this.foundDefaultDb = found; - } - - public String getSelectedDbPath() - { - int index = sequenceDbPathListBox.getSelectedIndex(); - if(index == -1) return ""; - return sequenceDbPathListBox.getValue(index); - } - - public String getSelectedDb() - { - StringBuilder sb = new StringBuilder(); - String separator = ""; - for (int i = 0; i < sequenceDbListBox.getItemCount(); i++) - { - if (sequenceDbListBox.isItemSelected(i)) - { - sb.append(separator); - sb.append(sequenceDbListBox.getValue(i)); - separator = ";"; - } - } - return sb.toString(); - } - - public void addChangeListener(ChangeHandler changeHandler) - { - sequenceDbPathListBox.addChangeHandler(changeHandler); - } - - @Override - public void setName(String name) { - sequenceDbListBox.setName(name); - sequenceDbPathListBox.setName(name + "Path"); - } - - @Override - public String getName() { - return sequenceDbListBox.getName(); - } - - @Override - public void setWidth(String width) - { - instance.setWidth(width); - sequenceDbListBox.setWidth(width); - sequenceDbPathListBox.setWidth(width); - } - - public void setVisibleItemCount(int itemCount) - { - sequenceDbListBox.setVisibleItemCount(itemCount); - } - - public void addRefreshClickHandler(ClickHandler handler) - { - refreshButton.addClickHandler(handler); - } - - public void addClickHandler(ClickHandler handler) - { - sequenceDbListBox.addClickHandler(handler); - } - - @Override - public void setReadOnly(boolean readOnly) - { - super.setReadOnly(readOnly); - String path = "/"; - String sequenceDbName = ""; - String dbWidgetName = ""; - - if(readOnly) - { - int pathIndex = sequenceDbPathListBox.getSelectedIndex(); - if( pathIndex != -1) - { - path = sequenceDbPathListBox.getValue(pathIndex); - } - sequenceDbName = getSelectedDb(); - instance.remove(dirPanel); - dbWidgetName = sequenceDbPathListBox.getName(); - sequenceDbPathHidden.setName(dbWidgetName); - sequenceDbPathHidden.setValue(path); - - instance.remove(sequenceDbListBox); - sequenceDbLabel.setText(sequenceDbName); - dbWidgetName = sequenceDbListBox.getName(); - sequenceDbHidden.setName(dbWidgetName); - sequenceDbHidden.setValue(sequenceDbName); - instance.insert(sequenceDbLabel, 0); - instance.add(sequenceDbHidden); - instance.add(sequenceDbPathHidden); - } - else - { - int labelIndex = instance.getWidgetIndex(sequenceDbLabel); - if(labelIndex != -1) - { - instance.remove(sequenceDbLabel); - instance.remove(sequenceDbHidden); - instance.remove(sequenceDbPathHidden); - instance.insert(dirPanel, 0); - instance.add(sequenceDbListBox); - } - } - } - - @Override - public Widget getLabel() - { - Label label = new Label("Protein database"); - label.setStylePrimaryName(LABEL_STYLE_NAME); - HorizontalPanel panel = new HorizontalPanel(); - panel.add(label); - panel.add(new HelpPopup("Protein Database", "A protein database defines the set of sequences that are searched for matches against the input spectra. This is typically in the FASTA format.")); - return panel; - } - - @Override - public String validate() - { - if (getSelectedDb().isEmpty() || getSelectedDb().equals("None found.") ) - { - return "A sequence database must be selected."; - } - return ""; - } - - abstract public void setTaxonomyListBoxContents(List taxonomyList); - abstract public String getSelectedTaxonomy(); - abstract public String setDefaultTaxonomy(String name); - abstract public void addTaxonomyChangeHandler(ChangeHandler listener); - - public void setLoading(boolean loading) - { - statusLabel.setText(loading ? "LOADING..." : ""); - } - - public void setEnabled(boolean paths, boolean files) - { - if (!paths) - { - sequenceDbPathListBox.clear(); - } - sequenceDbPathListBox.setEnabled(paths); - if (!files) - { - sequenceDbListBox.clear(); - } - sequenceDbListBox.setEnabled(files); - refreshButton.setEnabled(paths); - } - - @Override - public void syncFormToXml(ParamParser params) throws SearchFormException - { - params.setInputParameter(ParameterNames.SEQUENCE_DB, getSelectedDb()); - } - - protected class RefreshButton extends ImageButton - { - RefreshButton() - { - super("Refresh"); - } - - @Override - public void onClick(Widget sender) - { - } - } - - @Override - public String syncXmlToForm(ParamParser params) - { - String sequenceDb = params.getInputParameter(ParameterNames.SEQUENCE_DB); - if(sequenceDb == null || sequenceDb.equals("")) - { - sequenceDb = getSelectedDb(); - if(sequenceDb == null || sequenceDb.equals("")) - { - return ""; - } - else - { - try - { - params.setInputParameter(ParameterNames.SEQUENCE_DB, sequenceDb); - } - catch(SearchFormException e) - { - return "Cannot set \"" + ParameterNames.SEQUENCE_DB + "\" in XML: " + e.getMessage(); - } - } - } - else if(!sequenceDb.equals(getSelectedDb())) - { - _search.getSequenceDbs(sequenceDb); - } - - String taxonomy = params.getInputParameter(ParameterNames.TAXONOMY); - if(taxonomy == null || taxonomy.equals("")) - { - taxonomy = getSelectedTaxonomy(); - if(taxonomy != null && !taxonomy.equals("")) - { - try - { - params.setInputParameter(ParameterNames.TAXONOMY, taxonomy); - } - catch(SearchFormException e) - { - return "Cannot set protein, taxon in XML: " + e.getMessage(); - } - } - } - else if(!taxonomy.equals(getSelectedTaxonomy())) - { - return setDefaultTaxonomy(taxonomy); - } - return ""; - } - - @Override - public Set getHandledParameterNames() - { - return new HashSet(Arrays.asList(ParameterNames.SEQUENCE_DB, ParameterNames.TAXONOMY)); - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/TPPComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/TPPComposite.java deleted file mode 100644 index 17d75f8885..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/TPPComposite.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (c) 2012-2017 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.client; - -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; -import org.labkey.api.gwt.client.pipeline.GWTPipelineConfig; -import org.labkey.api.gwt.client.pipeline.GWTPipelineTask; -import org.labkey.api.gwt.client.ui.HelpPopup; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -/** - * UI to let user configure selected TPP parameters - * User: jeckels - * Date: Jan 20, 2012 - */ -public class TPPComposite extends SearchFormComposite implements PipelineConfigCallback -{ - protected FlexTable _instance = new FlexTable(); - private TextBox _peptideProphetTextBox = new TextBox(); - private TextBox _proteinProphetTextBox = new TextBox(); - private ListBox _quantitationAlgorithmListBox = new ListBox(); - private TextBox _massToleranceTextBox = new TextBox(); - private TextBox _residueLabeLMassTextBox = new TextBox(); - private TextBox _libraConfigNameTextBox = new TextBox(); - private ListBox _libraNormalizationChannelListBox = new ListBox(); - private final int _massToleranceRow; - private final int _residueLabelMassRow; - private final int _libraConfigNameRow; - private final int _libraNormalizationChannelRow; - private boolean _visible = false; - public static final int MAX_LIBRA_CHANNELS = 16; - - public TPPComposite() - { - int row = 0; - - HorizontalPanel minPepPropLabel = new HorizontalPanel(); - minPepPropLabel.add(new Label("Minimum PeptideProphet prob")); - minPepPropLabel.add(new HelpPopup("Minimum PeptideProphet prob", "The minimum value for a peptide's probability, as determined by PeptideProphet, to be retained in the analysis results. Values should be between 0 and 1, inclusive.")); - _instance.setStylePrimaryName("lk-fields-table"); - _instance.setWidget(row, 0, minPepPropLabel); - _instance.getCellFormatter().setStyleName(row, 0, "labkey-form-label-nowrap"); - _peptideProphetTextBox.setVisibleLength(4); - _peptideProphetTextBox.setName("minPeptideProphetProb"); - _instance.setText(row, 1, ""); - - HorizontalPanel minProtPropLabel = new HorizontalPanel(); - minProtPropLabel.add(new Label("Minimum ProteinProphet prob")); - minProtPropLabel.add(new HelpPopup("Minimum ProteinProphet prob", "The minimum value for a protein group's probability, as determined by ProteinProphet, to be retained in the analysis results. Values should be between 0 and 1, inclusive.")); - _instance.setWidget(++row, 0, minProtPropLabel); - _instance.getCellFormatter().setStyleName(row, 0, "labkey-form-label-nowrap"); - _proteinProphetTextBox.setVisibleLength(4); - _proteinProphetTextBox.setName("minProteinProphetProb"); - _instance.setText(row, 1, ""); - - HorizontalPanel quantEngineLabel = new HorizontalPanel(); - quantEngineLabel.add(new Label("Quantitation engine")); - quantEngineLabel.add(new HelpPopup("Quantitation engine", "

The tool to use for performing quantitation on isotopically labelled samples.

XPRESS can be used for Isotope-coded affinity tag (ICAT) or Stable isotope labeling by amino acids in cell culture (SILAC) experiments.

Libra analyzes Isobaric tag for relative and absolute quantitation (iTRAQ) samples.

")); - _instance.setWidget(++row, 0, quantEngineLabel); - _instance.getCellFormatter().setStyleName(row, 0, "labkey-form-label-nowrap"); - _quantitationAlgorithmListBox.addItem(""); - _quantitationAlgorithmListBox.addItem("Libra"); - _quantitationAlgorithmListBox.addItem("XPRESS"); - _quantitationAlgorithmListBox.setName("quantitationEngine"); - _instance.setText(row, 1, ""); - - HorizontalPanel quantResidueMasslLabel = new HorizontalPanel(); - quantResidueMasslLabel.add(new Label("Quantitation residue mass label")); - quantResidueMasslLabel.add(new HelpPopup("Quantitation residue mass label", "The mass of the quantitation label modification for the each modified amino acid. The format is M1@X1,M2@X2,..., Mn@Xn\n" + - "where Mi is a floating point number (modification mass in Daltons) and Xi is a single letter abbreviation for a type of amino acid residue. For example, '9.0@C'. See the X!Tandem documentation for more information.")); - _instance.setWidget(++row, 0, quantResidueMasslLabel); - _instance.getCellFormatter().setStyleName(row, 0, "labkey-form-label-nowrap"); - _residueLabeLMassTextBox.setVisibleLength(20); - _residueLabeLMassTextBox.setName("quantitationResidueLabel"); - _instance.setText(row, 1, ""); - _instance.getRowFormatter().setVisible(row, false); - _residueLabelMassRow = row; - - HorizontalPanel quantMassTolLabel = new HorizontalPanel(); - quantMassTolLabel.add(new Label("Quantitation mass tolerance")); - quantMassTolLabel.add(new HelpPopup("Quantitation mass tolerance", "The mass tolerance for XPRESS or Q3 quantitation. The default value is 1.0 daltons.")); - _instance.setWidget(++row, 0, quantMassTolLabel); - _instance.getCellFormatter().setStyleName(row, 0, "labkey-form-label-nowrap"); - _massToleranceTextBox.setVisibleLength(4); - _massToleranceTextBox.setName("quantitationMassTolerance"); - _instance.setText(row, 1, ""); - _instance.getRowFormatter().setVisible(row, false); - _massToleranceRow = row; - - HorizontalPanel libraConfigNameLabel = new HorizontalPanel(); - libraConfigNameLabel.add(new Label("Libra config name")); - libraConfigNameLabel.add(new HelpPopup("Libra config name", "The name of the Libra configuration file. Must be available on server's file system in /.labkey/protocols/libra/")); - _instance.setWidget(++row, 0, libraConfigNameLabel); - _instance.getCellFormatter().setStyleName(row, 0, "labkey-form-label-nowrap"); - _libraConfigNameTextBox.setVisibleLength(20); - _libraConfigNameTextBox.setName("libraConfigName"); - _instance.setText(row, 1, ""); - _instance.getRowFormatter().setVisible(row, false); - _libraConfigNameRow = row; - - HorizontalPanel libraChannelLabel = new HorizontalPanel(); - libraChannelLabel.add(new Label("Libra normalization channel")); - libraChannelLabel.add(new HelpPopup("Libra normalization channel", "The Libra quantitation channel number to be used for normalization.")); - _instance.setWidget(++row, 0, libraChannelLabel); - _instance.getCellFormatter().setStyleName(row, 0, "labkey-form-label-nowrap"); - for (int i = 1; i <= MAX_LIBRA_CHANNELS; i++) - { - _libraNormalizationChannelListBox.addItem(Integer.toString(i)); - } - _libraNormalizationChannelListBox.setName("libraNormalizationChannel"); - _instance.setText(row, 1, ""); - _instance.getRowFormatter().setVisible(row, false); - _libraNormalizationChannelRow = row; - - initWidget(_instance); - } - - @Override - public void setWidth(String width) - { - } - - @Override - public Widget getLabel() - { - Label label = new Label("Trans-Proteomic Pipeline"); - label.setStyleName(LABEL_STYLE_NAME); - HorizontalPanel panel = new HorizontalPanel(); - panel.add(label); - panel.add(new HelpPopup("Trans-Proteomic Pipeline", "The Trans-Proteomic Pipeline (TPP) is a suite of analysis tools from the Institute for Systems Biology (ISB). It provides key functionality for the MS2 analysis pipeline, including PeptideProphet, ProteinProphet, and quantitation tools.")); - return panel; - } - - @Override - public String validate() - { - if (!validateNumber(_peptideProphetTextBox, 0, 1, true)) - return "Minimum PeptideProphet probability must be a number between 0 and 1, inclusive"; - if (!validateNumber(_proteinProphetTextBox, 0, 1, true)) - return "Minimum ProteinProphet probability must be a number between 0 and 1, inclusive"; - if (isLibra()) - { - if (_libraConfigNameTextBox.getText().trim().isEmpty()) - return "Libra configuration name is required"; - } - if (isXPRESS() || isQ3()) - { - if (!validateNumber(_massToleranceTextBox, 0, Double.MAX_VALUE, true)) - return "Mass tolerance must be a non-negative number"; - if (_residueLabeLMassTextBox.getText().trim().isEmpty()) - return "Residue label mass is required when using XPRESS or Q3"; - } - return ""; - } - - private boolean isXPRESS() - { - return "xpress".equalsIgnoreCase(_quantitationAlgorithmListBox.getItemText(_quantitationAlgorithmListBox.getSelectedIndex())); - } - - private boolean isLibra() - { - return "libra".equalsIgnoreCase(_quantitationAlgorithmListBox.getItemText(_quantitationAlgorithmListBox.getSelectedIndex())); - } - - private boolean isQ3() - { - return "q3".equalsIgnoreCase(_quantitationAlgorithmListBox.getItemText(_quantitationAlgorithmListBox.getSelectedIndex())); - } - - private void setQuantitationVisibility() - { - boolean xpress = isXPRESS(); - boolean q3 = isQ3(); - boolean libra = isLibra(); - _instance.getRowFormatter().setVisible(_massToleranceRow, xpress || q3); - _instance.getRowFormatter().setVisible(_residueLabelMassRow, xpress || q3); - _instance.getRowFormatter().setVisible(_libraConfigNameRow, libra); - _instance.getRowFormatter().setVisible(_libraNormalizationChannelRow, libra); - } - - private boolean validateNumber(TextBox textBox, double min, double max, boolean isDouble) - { - String s = textBox.getText().trim(); - if (!s.isEmpty()) - { - try - { - double d = isDouble ? Double.parseDouble(s) : Integer.parseInt(s); - if (d < min || d > max) - { - return false; - } - } - catch (NumberFormatException e) - { - return false; - } - } - return true; - } - - @Override - public void setName(String name) - { - - } - - @Override - public String getName() - { - return null; - } - - /** Callback from requesting info on the pipeline tasks and potential execution locations */ - @Override - public void setPipelineConfig(GWTPipelineConfig result) - { - for (GWTPipelineTask task : result.getTasks()) - { - if ("tpp".equalsIgnoreCase(task.getGroupName()) || "tpp fractions".equalsIgnoreCase(task.getGroupName())) - { - _visible = true; - setVisibilityInParentTable(); - return; - } - } - } - - @Override - public void syncFormToXml(ParamParser params) throws SearchFormException - { - syncFormToXml(_peptideProphetTextBox, ParameterNames.MIN_PEPTIDE_PROPHET_PROBABILITY, params); - syncFormToXml(_proteinProphetTextBox, ParameterNames.MIN_PROTEIN_PROPHET_PROBABILITY, params); - syncFormToXml(_massToleranceTextBox, ParameterNames.QUANTITATION_MASS_TOLERANCE, params); - syncFormToXml(_residueLabeLMassTextBox, ParameterNames.QUANTITATION_RESIDUE_LABEL_MASS, params); - if (isLibra()) - { - syncFormToXml(_libraConfigNameTextBox, ParameterNames.LIBRA_CONFIG_NAME_PARAM, params); - params.setInputParameter(ParameterNames.LIBRA_NORMALIZATION_CHANNEL_PARAM, _libraNormalizationChannelListBox.getItemText(_libraNormalizationChannelListBox.getSelectedIndex())); - } - else - { - params.removeInputParameter(ParameterNames.LIBRA_CONFIG_NAME_PARAM); - params.removeInputParameter(ParameterNames.LIBRA_NORMALIZATION_CHANNEL_PARAM); - } - - if (_quantitationAlgorithmListBox.getSelectedIndex() == 0) - { - params.removeInputParameter(ParameterNames.QUANTITATION_ALGORITHM); - } - else - { - String selected = _quantitationAlgorithmListBox.getItemText(_quantitationAlgorithmListBox.getSelectedIndex()).toLowerCase(); - params.setInputParameter(ParameterNames.QUANTITATION_ALGORITHM, selected); - } - } - - private void syncFormToXml(TextBox textBox, String paramName, ParamParser params) throws SearchFormException - { - String value = textBox.getText().trim(); - if (value.isEmpty()) - { - params.removeInputParameter(paramName); - } - else - { - params.setInputParameter(paramName, value); - } - } - - @Override - public String syncXmlToForm(ParamParser params) - { - String minPeptide = params.getInputParameter(ParameterNames.MIN_PEPTIDE_PROPHET_PROBABILITY); - _peptideProphetTextBox.setText(minPeptide == null ? "" : minPeptide); - - String minProtein = params.getInputParameter(ParameterNames.MIN_PROTEIN_PROPHET_PROBABILITY); - _proteinProphetTextBox.setText(minProtein == null ? "" : minProtein); - - String massTolerance = params.getInputParameter(ParameterNames.QUANTITATION_MASS_TOLERANCE); - _massToleranceTextBox.setText(massTolerance == null ? "" : massTolerance); - - String residueLabelMass = params.getInputParameter(ParameterNames.QUANTITATION_RESIDUE_LABEL_MASS); - _residueLabeLMassTextBox.setText(residueLabelMass == null ? "" : residueLabelMass); - - String libraConfigName = params.getInputParameter(ParameterNames.LIBRA_CONFIG_NAME_PARAM); - _libraConfigNameTextBox.setText(libraConfigName == null ? "" : libraConfigName); - - String libraNormalizationChannel = params.getInputParameter(ParameterNames.LIBRA_NORMALIZATION_CHANNEL_PARAM); - if (libraNormalizationChannel != null && !libraNormalizationChannel.isEmpty()) - { - try - { - int channel = Integer.parseInt(libraNormalizationChannel); - // Drop-down is 1-16, to translate to index - int index = channel - 1; - if (index < 0 || index >= _libraNormalizationChannelListBox.getItemCount()) - { - return "Invalid Libra normalization channel: " + libraNormalizationChannel; - } - _libraNormalizationChannelListBox.setSelectedIndex(index); - } - catch (NumberFormatException e) - { - return "Invalid Libra normalization channel: " + libraNormalizationChannel; - } - } - else - { - _libraNormalizationChannelListBox.setSelectedIndex(0); - } - - String quantEngine = params.getInputParameter(ParameterNames.QUANTITATION_ALGORITHM); - if (quantEngine != null && !quantEngine.isEmpty()) - { - boolean found = false; - for (int i = 0; i < _quantitationAlgorithmListBox.getItemCount(); i++) - { - if (_quantitationAlgorithmListBox.getItemText(i).equalsIgnoreCase(quantEngine)) - { - found = true; - _quantitationAlgorithmListBox.setSelectedIndex(i); - } - } - if (!found) - { - return "Unknown quantitation engine: " + quantEngine; - } - } - else - { - _quantitationAlgorithmListBox.setSelectedIndex(0); - } - setQuantitationVisibility(); - - // Check the probability values - return validate(); - } - - @Override - public void setReadOnly(boolean readOnly) - { - super.setReadOnly(readOnly); - int row = 0; - if (readOnly) - { - _instance.setText(0, 1, _peptideProphetTextBox.getText().trim().isEmpty() ? "" : _peptideProphetTextBox.getText()); - _instance.setText(++row, 1, _proteinProphetTextBox.getText().trim().isEmpty() ? "" : _proteinProphetTextBox.getText()); - _instance.setText(++row, 1, _quantitationAlgorithmListBox.getItemText(_quantitationAlgorithmListBox.getSelectedIndex())); - _instance.setText(++row, 1, _residueLabeLMassTextBox.getText().trim().isEmpty() ? "" : _residueLabeLMassTextBox.getText()); - _instance.setText(++row, 1, _massToleranceTextBox.getText().trim().isEmpty() ? "" : _massToleranceTextBox.getText()); - _instance.setText(++row, 1, _libraConfigNameTextBox.getText().trim().isEmpty() ? "" : _libraConfigNameTextBox.getText()); - _instance.setText(++row, 1, _libraNormalizationChannelListBox.getItemText(_libraNormalizationChannelListBox.getSelectedIndex())); - } - else - { - _instance.setWidget(row, 1, _peptideProphetTextBox); - _instance.setWidget(++row, 1, _proteinProphetTextBox); - _instance.setWidget(++row, 1, _quantitationAlgorithmListBox); - _instance.setWidget(++row, 1, _residueLabeLMassTextBox); - _instance.setWidget(++row, 1, _massToleranceTextBox); - _instance.setWidget(++row, 1, _libraConfigNameTextBox); - _instance.setWidget(++row, 1, _libraNormalizationChannelListBox); - setQuantitationVisibility(); - } - } - - public void addChangeListener(ChangeHandler handler) - { - _peptideProphetTextBox.addChangeHandler(handler); - _proteinProphetTextBox.addChangeHandler(handler); - _quantitationAlgorithmListBox.addChangeHandler(handler); - _quantitationAlgorithmListBox.addChangeHandler(new ChangeHandler() - { - @Override - public void onChange(ChangeEvent event) - { - setQuantitationVisibility(); - } - }); - _massToleranceTextBox.addChangeHandler(handler); - _residueLabeLMassTextBox.addChangeHandler(handler); - _libraConfigNameTextBox.addChangeHandler(handler); - _libraNormalizationChannelListBox.addChangeHandler(handler); - } - - @Override - public void configureCompositeRow(FlexTable table, int row) - { - super.configureCompositeRow(table, row); - setVisibilityInParentTable(); - } - - private void setVisibilityInParentTable() - { - _parentTable.getRowFormatter().setVisible(_parentTableRow, _visible); - } - - @Override - public Set getHandledParameterNames() - { - return new HashSet(Arrays.asList( - ParameterNames.MIN_PROTEIN_PROPHET_PROBABILITY, - ParameterNames.MIN_PEPTIDE_PROPHET_PROBABILITY, - ParameterNames.QUANTITATION_ALGORITHM, - ParameterNames.QUANTITATION_MASS_TOLERANCE, - ParameterNames.QUANTITATION_RESIDUE_LABEL_MASS, - ParameterNames.LIBRA_CONFIG_NAME_PARAM, - ParameterNames.LIBRA_NORMALIZATION_CHANNEL_PARAM)); - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotEnzymeComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotEnzymeComposite.java deleted file mode 100644 index 4473366f96..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotEnzymeComposite.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2008-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.mascot; - -import org.labkey.ms2.pipeline.client.EnzymeComposite; - -/** - * User: billnelson@uky.edu - * Date: Apr 29, 2008 - */ - -/** - * MascotEnzymeComposite - */ -public class MascotEnzymeComposite extends EnzymeComposite -{ - @Override - public String setSelectedEnzyme(String enzymeSignature) - { - if(enzymeSignature == null) return "Cut site is equal to null."; - int numEnz = enzymeListBox.getItemCount(); - boolean found = false; - for(int i = 0; i < numEnz; i++) - { - if(enzymeSignature.equals(enzymeListBox.getValue(i))) - { - enzymeListBox.setSelectedIndex(i); - found = true; - break; - } - } - if(found) return ""; - return "The enzyme '" + enzymeSignature + "' was not found."; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotResidueModComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotResidueModComposite.java deleted file mode 100644 index a497f29764..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotResidueModComposite.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2008-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.mascot; - -import org.labkey.ms2.pipeline.client.ResidueModComposite; -import org.labkey.ms2.pipeline.client.Search; - -import java.util.*; - -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.FlexTable; - -/** - * User: billnelson@uky.edu - * Date: Apr 30, 2008 - */ - -/** - * MascotResidueModComposite - */ -public class MascotResidueModComposite extends ResidueModComposite -{ - public MascotResidueModComposite(Search searchForm) - { - this.searchForm = searchForm; - FlexTable.FlexCellFormatter staticFormatter = staticFlexTable.getFlexCellFormatter(); - staticFormatter.setRowSpan(0, 0, 2); - staticFormatter.setRowSpan(0, 2, 2); - FlexTable.FlexCellFormatter dynamicFormatter = dynamicFlexTable.getFlexCellFormatter(); - dynamicFormatter.setRowSpan(0, 0, 2); - dynamicFormatter.setRowSpan(0, 2, 2); - staticFlexTable.setWidget(0, 0, modStaticListBox); - staticFlexTable.setWidget(0, 2, staticPanel); - staticFlexTable.setWidget(0, 1, addStaticButton); - dynamicFlexTable.setWidget(0, 0, modDynamicListBox); - dynamicFlexTable.setWidget(0, 2, dynamicPanel); - dynamicFlexTable.setWidget(0, 1, addDynamicButton); - instance.setWidget(modTabPanel); - } - - @Override - public String validate() - { - String error = validate(staticListBox); - if(error.length()> 0) return error; - error = validate(dynamicListBox); - return error; - } - - String validate(ListBox box) - { - Map modMap = getListBoxMap(box); - - for(String modName : modMap.keySet()) - { - if(find(modName, modStaticListBox) == -1) return "modification mass contained an invalid value(" + modName + ")."; - } - return ""; - } - - @Override - public Map getModMap(int modType) - { - return getListBoxMap(modStaticListBox); - } - - @Override - public void update(Map mod0Map, Map mod1Map) - { - setListBoxMods(mod0Map, modStaticListBox); - //there the same in mascot - setListBoxMods(mod0Map, modDynamicListBox); - } - - @Override - protected String validate(ListBox box, int modType) - { - Map modMap = getListBoxMap(box); - - for(Map.Entry entry : modMap.entrySet()) - { - String error = validateModification(entry.getKey(), entry.getValue(), modStaticListBox); - if (error != null) - { - return error; - } - } - return ""; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotSequenceDbComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotSequenceDbComposite.java deleted file mode 100644 index 009302c324..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/mascot/MascotSequenceDbComposite.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2008-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.mascot; - -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.user.client.ui.*; -import org.labkey.ms2.pipeline.client.ParamParser; -import org.labkey.ms2.pipeline.client.ParameterNames; -import org.labkey.ms2.pipeline.client.Search; -import org.labkey.ms2.pipeline.client.SearchFormException; -import org.labkey.ms2.pipeline.client.SequenceDbComposite; - -import java.util.List; - -/** - * User: billnelson@uky.edu - * Date: Apr 22, 2008 - */ - -/** - * MascotSequenceDbComposite - */ -public class MascotSequenceDbComposite extends SequenceDbComposite -{ - - private ListBox taxonomyListBox = new ListBox(); - private Label taxonomyReadOnly = new Label(); - private Label taxonomyLabel = new Label(); - private Label databaseLabel = new Label(); - protected VerticalPanel labelWidget; - - - public MascotSequenceDbComposite(Search search) - { - super(search, true); - sequenceDbLabel.setStylePrimaryName("ms-readonly"); - instance.add(sequenceDbListBox); - taxonomyReadOnly.setStylePrimaryName("labkey-read-only"); - taxonomyListBox.setVisibleItemCount(1); - instance.add(taxonomyListBox); - labelWidget = new VerticalPanel(); - initLabel(false); - } - - private void initLabel(boolean readonly) - { - taxonomyLabel.setText("Taxonomy"); - labelWidget.clear(); - if(readonly) - { - databaseLabel.setText("Database"); - labelWidget.add(databaseLabel); - labelWidget.add(taxonomyLabel); - } - else - { - databaseLabel.setText("Databases"); - labelWidget.add(databaseLabel); - labelWidget.add(new Label(" ")); - labelWidget.add(new Label(" ")); - labelWidget.add(new Label(" ")); - labelWidget.add(new Label(" ")); - labelWidget.add(taxonomyLabel); - } - } - - @Override - public void update(List files, List directories, String defaultDb, List taxonomy) - { - super.update(files, directories, defaultDb, taxonomy); - setTaxonomyListBoxContents(taxonomy); - } - - @Override - public void setTaxonomyListBoxContents(List taxonomy) - { - if(taxonomy == null) return; - for (String s : taxonomy) - { - taxonomyListBox.addItem(s); - } - } - - @Override - public Widget getLabel() - { - setLabelStyle(); - return labelWidget; - } - - private void setLabelStyle() - { - String style = "labkey-form-label"; - int widgetCount = labelWidget.getWidgetCount(); - for(int i = 0; i < widgetCount; i++) - { - Label l = (Label)labelWidget.getWidget(i); - l.setStylePrimaryName(style); - } - } - - @Override - public void setWidth(String width) - { - super.setWidth(width); - taxonomyListBox.setWidth(width); - } - - @Override - public void setReadOnly(boolean readOnly) - { - super.setReadOnly(readOnly); - String sequenceDbName; - String dbWidgetName; - String taxonomyName = ""; - - if(readOnly) - { - sequenceDbName = getSelectedDb(); - - instance.remove(sequenceDbListBox); - sequenceDbLabel.setText(sequenceDbName); - dbWidgetName = sequenceDbListBox.getName(); - sequenceDbHidden.setName(dbWidgetName); - sequenceDbHidden.setValue(sequenceDbName); - - int taxonomyIndex = taxonomyListBox.getSelectedIndex(); - if(taxonomyIndex != -1) - { - taxonomyName = taxonomyListBox.getValue(taxonomyIndex); - } - instance.remove(taxonomyListBox); - taxonomyReadOnly.setText(taxonomyName); - - instance.insert(sequenceDbLabel, 0); - instance.insert(taxonomyReadOnly,1); - instance.add(sequenceDbHidden); - instance.add(sequenceDbPathHidden); - } - else - { - int labelIndex = instance.getWidgetIndex(sequenceDbLabel); - if(labelIndex != -1) - { - instance.remove(sequenceDbLabel); - instance.remove(sequenceDbHidden); - instance.remove(sequenceDbPathHidden); - instance.insert(dirPanel, 0); - instance.add(sequenceDbListBox); - } - labelIndex = instance.getWidgetIndex(taxonomyReadOnly); - if( labelIndex != -1) - { - instance.remove(taxonomyReadOnly); - instance.add(taxonomyListBox); - } - } - initLabel(readOnly); - } - - @Override - public String getSelectedDbPath() - { - return ""; - } - - @Override - public String getSelectedTaxonomy() - { - int index = taxonomyListBox.getSelectedIndex(); - if(index == -1) return ""; - return taxonomyListBox.getValue(index); - } - - @Override - public void syncFormToXml(ParamParser params) throws SearchFormException - { - super.syncFormToXml(params); - params.setInputParameter(ParameterNames.TAXONOMY, getSelectedTaxonomy()); - } - - @Override - public String setDefaultTaxonomy(String tax) - { - int taxCount = taxonomyListBox.getItemCount(); - boolean foundTax = false; - for(int i = 0; i < taxCount; i++) - { - if(tax.equals(taxonomyListBox.getValue(i))) - { - taxonomyListBox.setSelectedIndex(i); - foundTax = true; - } - } - if(!foundTax) - return "The taxon '" + tax + "' is not found on the Mascot server."; - return ""; - } - - @Override - public void addTaxonomyChangeHandler(ChangeHandler handler) { - taxonomyListBox.addChangeHandler(handler); - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/sequest/SequestResidueModComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/sequest/SequestResidueModComposite.java deleted file mode 100644 index cad2ac0f11..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/sequest/SequestResidueModComposite.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2008-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.sequest; - -import org.labkey.ms2.pipeline.client.ResidueModComposite; -import org.labkey.ms2.pipeline.client.Search; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.ListBox; - -import java.util.Map; - -/** - * User: billnelson@uky.edu - * Date: Apr 30, 2008 - */ - -/** - * SequestResidueModComposite - */ -public class SequestResidueModComposite extends ResidueModComposite -{ - - public SequestResidueModComposite(Search searchForm) - { - this.searchForm = searchForm; - - FlexTable.FlexCellFormatter staticFormatter = staticFlexTable.getFlexCellFormatter(); - staticFormatter.setRowSpan(0, 0, 2); - staticFormatter.setRowSpan(0, 2, 2); - FlexTable.FlexCellFormatter dynamicFormatter = dynamicFlexTable.getFlexCellFormatter(); - dynamicFormatter.setRowSpan(0, 0, 2); - dynamicFormatter.setRowSpan(0, 2, 2); - staticFlexTable.setWidget(0, 0, modStaticListBox); - staticFlexTable.setWidget(0, 2, staticPanel); - staticFlexTable.setWidget(0, 1, addStaticButton); - staticFlexTable.setWidget(1, 0, newStaticButton); - dynamicFlexTable.setWidget(0, 0, modDynamicListBox); - dynamicFlexTable.setWidget(0, 2, dynamicPanel); - dynamicFlexTable.setWidget(0, 1, addDynamicButton); - dynamicFlexTable.setWidget(1, 0, newDynamicButton); - instance.setWidget(modTabPanel); - } - - @Override - public void update(Map mod0Map, Map mod1Map) - { - setListBoxMods(mod0Map, modStaticListBox); - setListBoxMods(mod1Map, modDynamicListBox); - } - - @Override - public Map getModMap(int modType) - { - if(modType == STATIC) - return getListBoxMap(modStaticListBox); - else if(modType == DYNAMIC) - return getListBoxMap(modDynamicListBox); - return null; - } - - @Override - protected String validate(ListBox box, int modType) - { - Map modMap = getListBoxMap(box); - ListBox defaultModListBox; - if(modType == STATIC) defaultModListBox = modStaticListBox; - else defaultModListBox = modDynamicListBox; - - for(Map.Entry entry : modMap.entrySet()) - { - String error = validateModification(entry.getKey(), entry.getValue(), defaultModListBox); - if (error != null) - { - return error; - } - } - return ""; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/sequest/SimpleSequenceDbComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/sequest/SimpleSequenceDbComposite.java deleted file mode 100644 index 1b0f65a212..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/sequest/SimpleSequenceDbComposite.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.sequest; - -import com.google.gwt.event.dom.client.ChangeHandler; -import org.labkey.ms2.pipeline.client.Search; -import org.labkey.ms2.pipeline.client.SequenceDbComposite; - -import java.util.List; - -/** - * User: billnelson@uky.edu - * Date: Apr 22, 2008 - */ - -/** - * SimpleSequenceDbComposite - */ -public class SimpleSequenceDbComposite extends SequenceDbComposite -{ - - public SimpleSequenceDbComposite(Search search) - { - super(search, false); - } - - @Override - public void setTaxonomyListBoxContents(List taxonomyList) - { - //No Mascot style taxonomy in Sequest - } - - @Override - public String getSelectedTaxonomy() - { - //No Mascot style taxonomy in Sequest - return null; - } - - @Override - public String setDefaultTaxonomy(String name) - { - //No Mascot style taxonomy in Sequest - return null; - } - - @Override - public void addTaxonomyChangeHandler(ChangeHandler handler) { - //No Mascot style taxonomy in Sequest - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemInputXmlComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemInputXmlComposite.java deleted file mode 100644 index 8e4d84516f..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemInputXmlComposite.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2008-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.tandem; - -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.HasText; -import org.labkey.api.gwt.client.ui.HelpPopup; -import org.labkey.ms2.pipeline.client.InputXmlComposite; -import org.labkey.ms2.pipeline.client.ParamParser; - -/** - * User: billnelson@uky.edu - * Date: Apr 18, 2008 - */ - -/** - * XtandemInputXmlComposite - */ -public class XtandemInputXmlComposite extends InputXmlComposite -{ - - @Override - public String update(String text) - { - if(params == null) - params = new XtandemParamParser(inputXmlTextArea); - return super.update(text); - } - - @Override - public Widget getLabel() - { - Label label = new Label("X! Tandem XML"); - label.setStyleName(LABEL_STYLE_NAME); - HorizontalPanel panel = new HorizontalPanel(); - panel.add(label); - panel.add(new HelpPopup("X! Tandem XML", "The full set of analysis parameters, represented in XML.")); - return panel; - } - - private class XtandemParamParser extends ParamParser - { - private XtandemParamParser(HasText xml) - { - super(xml); - } - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemResidueModComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemResidueModComposite.java deleted file mode 100644 index aaf5aa5d50..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemResidueModComposite.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2008-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.tandem; - -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.ListBox; -import org.labkey.ms2.pipeline.client.ResidueModComposite; -import org.labkey.ms2.pipeline.client.Search; - -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * User: billnelson@uky.edu - * Date: Apr 30, 2008 - */ - -/** - * XtandemResidueModComposite - */ -public class XtandemResidueModComposite extends ResidueModComposite -{ - public XtandemResidueModComposite(Search searchForm) - { - this.searchForm = searchForm; - - FlexTable.FlexCellFormatter staticFormatter = staticFlexTable.getFlexCellFormatter(); - staticFormatter.setRowSpan(0, 0, 2); - staticFormatter.setRowSpan(0, 2, 2); - FlexTable.FlexCellFormatter dynamicFormatter = dynamicFlexTable.getFlexCellFormatter(); - dynamicFormatter.setRowSpan(0, 0, 2); - dynamicFormatter.setRowSpan(0, 2, 2); - staticFlexTable.setWidget(0, 0, modStaticListBox); - staticFlexTable.setWidget(0, 2, staticPanel); - staticFlexTable.setWidget(0, 1, addStaticButton); - staticFlexTable.setWidget(1, 0, newStaticButton); - dynamicFlexTable.setWidget(0, 0, modDynamicListBox); - dynamicFlexTable.setWidget(0, 2, dynamicPanel); - dynamicFlexTable.setWidget(0, 1, addDynamicButton); - dynamicFlexTable.setWidget(1, 0, newDynamicButton); - instance.setWidget(modTabPanel); - } - - @Override - public void update(Map mod0Map, Map mod1Map) - { - setListBoxMods(mod0Map, modStaticListBox); - setListBoxMods(mod1Map, modDynamicListBox); - } - - @Override - public Map getModMap(int modType) - { - if(modType == STATIC) - return getListBoxMap(modStaticListBox); - else if(modType == DYNAMIC) - return getListBoxMap(modDynamicListBox); - return null; - } - - @Override - protected String validate(ListBox box, int modType) - { - Map modMap = getListBoxMap(box); - ListBox defaultModListBox; - if(modType == STATIC) defaultModListBox = modStaticListBox; - else defaultModListBox = modDynamicListBox; - - for(Map.Entry entry : modMap.entrySet()) - { - String error = validateModification(entry.getKey(), entry.getValue(), defaultModListBox); - if (error != null) - { - return error; - } - } - return ""; - } -} diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemSequenceDbComposite.java b/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemSequenceDbComposite.java deleted file mode 100644 index 493a260383..0000000000 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/tandem/XtandemSequenceDbComposite.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2008-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline.client.tandem; - -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.core.client.GWT; -import org.labkey.ms2.pipeline.client.Search; -import org.labkey.ms2.pipeline.client.SequenceDbComposite; - -import java.util.List; - -/** - * User: billnelson@uky.edu - * Date: Apr 17, 2008 - */ - -/** - * XtandemSequenceDbComposite - */ - -public class XtandemSequenceDbComposite extends SequenceDbComposite -{ - public XtandemSequenceDbComposite(Search search) - { - super(search, true); - - dirPanel.insert(refreshPanel, 1); - refreshPanel.add(refreshButton); - } - - @Override - public void setWidth(String width) - { - super.setWidth(width); - int intWidth = 0; - StringBuffer num = new StringBuffer(); - StringBuffer type = new StringBuffer(); - StringBuffer newWidth = new StringBuffer(); - for(int i = 0; i < width.length(); i++) - { - char widthChar = width.charAt(i); - if(Character.isDigit(widthChar)) - { - num.append(widthChar); - } - else - { - type.append(widthChar); - } - } - try - { - intWidth = Integer.parseInt(num.toString()); - if(intWidth < 60) throw new NumberFormatException("The database path ListBox is too small"); - newWidth.append(Integer.toString(intWidth - (60 + 3))); - newWidth.append(type); - sequenceDbPathListBox.setWidth(newWidth.toString()); - refreshPanel.setWidth("60px"); - - } - catch(NumberFormatException e) - {} - } - - @Override - public void addClickHandler(ClickHandler handler) - { - if(GWT.getTypeName(handler).equals("org.labkey.ms2.pipeline.client.Search$RefreshSequenceDbPathsClickListener")) - refreshButton.addClickHandler(handler); - else - super.addClickHandler(handler); - } - - @Override - public void setTaxonomyListBoxContents(List taxonomyList) - { - //No Mascot style taxonomy in X! Tandem - } - - @Override - public String getSelectedTaxonomy() - { - //No Mascot style taxonomy in X! Tandem - return null; - } - - @Override - public String setDefaultTaxonomy(String name) - { - //No Mascot style taxonomy in X! Tandem - return null; - } - - @Override - public void addTaxonomyChangeHandler(ChangeHandler handler) { - ///No Mascot style taxonomy in X! Tandem - } -} diff --git a/ms2/src/org/labkey/ms2/MS2Module.java b/ms2/src/org/labkey/ms2/MS2Module.java index 2dc56425bc..793ac37909 100644 --- a/ms2/src/org/labkey/ms2/MS2Module.java +++ b/ms2/src/org/labkey/ms2/MS2Module.java @@ -67,7 +67,6 @@ import org.labkey.ms2.pipeline.comet.CometPipelineProvider; import org.labkey.ms2.pipeline.mascot.MascotCPipelineProvider; import org.labkey.ms2.pipeline.mascot.MascotClientImpl; -import org.labkey.ms2.pipeline.rollup.FractionRollupPipelineProvider; import org.labkey.ms2.pipeline.sequest.BooleanParamsValidator; import org.labkey.ms2.pipeline.sequest.ListParamsValidator; import org.labkey.ms2.pipeline.sequest.MultipleDoubleParamsValidator; @@ -105,7 +104,7 @@ public class MS2Module extends SpringModule implements ProteomicsModule { public static final String WEBPART_PEP_SEARCH = "Peptide Search"; - public static final MS2SearchExperimentRunType SEARCH_RUN_TYPE = new MS2SearchExperimentRunType("MS2 Searches", MS2Schema.TableType.MS2SearchRuns.toString(), Handler.Priority.MEDIUM, MS2Schema.XTANDEM_PROTOCOL_OBJECT_PREFIX, MS2Schema.SEQUEST_PROTOCOL_OBJECT_PREFIX, MS2Schema.MASCOT_PROTOCOL_OBJECT_PREFIX, MS2Schema.COMET_PROTOCOL_OBJECT_PREFIX, MS2Schema.IMPORTED_SEARCH_PROTOCOL_OBJECT_PREFIX, MS2Schema.FRACTION_ROLLUP_PROTOCOL_OBJECT_PREFIX); + public static final MS2SearchExperimentRunType SEARCH_RUN_TYPE = new MS2SearchExperimentRunType("MS2 Searches", MS2Schema.TableType.MS2SearchRuns.toString(), Handler.Priority.MEDIUM, MS2Schema.XTANDEM_PROTOCOL_OBJECT_PREFIX, MS2Schema.SEQUEST_PROTOCOL_OBJECT_PREFIX, MS2Schema.MASCOT_PROTOCOL_OBJECT_PREFIX, MS2Schema.COMET_PROTOCOL_OBJECT_PREFIX, MS2Schema.IMPORTED_SEARCH_PROTOCOL_OBJECT_PREFIX); public static final String MS2_RUNS_NAME = "MS2 Runs"; public static final String MS2_MODULE_NAME = "MS2"; @@ -188,7 +187,6 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext) service.registerPipelineProvider(new MascotCPipelineProvider(this), "Mascot (Cluster)"); service.registerPipelineProvider(new SequestPipelineProvider(this)); service.registerPipelineProvider(new CometPipelineProvider(this), "Comet"); - service.registerPipelineProvider(new FractionRollupPipelineProvider(this)); service.registerPipelineProvider(new ProteinProphetPipelineProvider(this)); final Set runTypes = new HashSet<>(); @@ -198,7 +196,6 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext) runTypes.add(new MS2SearchExperimentRunType("Comet Searches", MS2Schema.TableType.CometSearchRuns.toString(), Handler.Priority.HIGH, MS2Schema.COMET_PROTOCOL_OBJECT_PREFIX)); runTypes.add(new MS2SearchExperimentRunType("Mascot Searches", MS2Schema.TableType.MascotSearchRuns.toString(), Handler.Priority.HIGH, MS2Schema.MASCOT_PROTOCOL_OBJECT_PREFIX)); runTypes.add(new MS2SearchExperimentRunType("Sequest Searches", MS2Schema.TableType.SequestSearchRuns.toString(), Handler.Priority.HIGH, MS2Schema.SEQUEST_PROTOCOL_OBJECT_PREFIX)); - runTypes.add(new MS2SearchExperimentRunType("Fraction Rollups", MS2Schema.TableType.FractionRollupsRuns.toString(), Handler.Priority.HIGH, MS2Schema.FRACTION_ROLLUP_PROTOCOL_OBJECT_PREFIX)); ExperimentService.get().registerExperimentRunTypeSource(container -> { diff --git a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2PipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2PipelineProvider.java index 4b1e28fb2d..04bab7b9f8 100644 --- a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2PipelineProvider.java +++ b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2PipelineProvider.java @@ -17,30 +17,31 @@ import org.labkey.api.data.Container; import org.labkey.api.module.Module; +import org.labkey.api.pipeline.PipelineJobService; import org.labkey.api.pipeline.PipelineValidationException; +import org.labkey.api.pipeline.TaskId; import org.labkey.api.pipeline.TaskPipeline; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; import org.labkey.api.pipeline.file.AbstractFileAnalysisProvider; - -import java.io.File; -import java.io.IOException; +import org.labkey.api.pipeline.file.FileAnalysisTaskPipeline; /** * Shared between search-engine pipeline providers and ones that operate on existing search results. * Created by: jeckels * Date: 8/23/15 */ -public abstract class AbstractMS2PipelineProvider extends AbstractFileAnalysisProvider +public abstract class AbstractMS2PipelineProvider> extends AbstractFileAnalysisProvider> { public AbstractMS2PipelineProvider(String name, Module owningModule) { super(name, owningModule); } - /** @throws org.labkey.api.pipeline.PipelineValidationException if the provider should not be available on the current server - * @param container*/ + /** @throws org.labkey.api.pipeline.PipelineValidationException if the provider should not be available on the current server */ abstract public void ensureEnabled(Container container) throws PipelineValidationException; + protected abstract String getActionId(); + abstract public AbstractMS2SearchProtocolFactory getProtocolFactory(); /** @return the name of the help topic that the user can consult for guidance on setting parameters */ @@ -49,5 +50,15 @@ public AbstractMS2PipelineProvider(String name, Module owningModule) /** @return true if this will be a full-blown search, false if it's operating on already searched-data */ abstract public boolean isSearch(); - abstract public boolean dbExists(Container container, File sequenceRoot, String dbName) throws IOException; + protected FileAnalysisTaskPipeline getTaskPipeline(TaskId id) + { + for (TaskPipeline taskPipeline : PipelineJobService.get().getTaskPipelines(null)) + { + if (taskPipeline.getId().equals(id) && taskPipeline instanceof FileAnalysisTaskPipeline fatp) + { + return fatp; + } + } + throw new IllegalStateException("Couldn't find task pipeline: " + id); + } } diff --git a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineJob.java b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineJob.java index a199445fda..b2df0cb14f 100644 --- a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineJob.java +++ b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineJob.java @@ -24,7 +24,6 @@ import org.labkey.api.pipeline.TaskFactorySettings; import org.labkey.api.pipeline.TaskId; import org.labkey.api.pipeline.file.AbstractFileAnalysisJob; -import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocol; import org.labkey.api.util.FileType; import org.labkey.api.util.FileUtil; import org.labkey.api.util.NetworkDrive; @@ -33,6 +32,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.*; /** @@ -77,18 +77,17 @@ protected AbstractMS2SearchPipelineJob(@JsonProperty("_dirSequenceRoot") File di _dirSequenceRoot = dirSequenceRoot; } - public AbstractMS2SearchPipelineJob(AbstractFileAnalysisProtocol protocol, + public AbstractMS2SearchPipelineJob(AbstractMS2SearchProtocol protocol, String providerName, ViewBackgroundInfo info, PipeRoot root, String protocolName, - File dirSequenceRoot, - File fileParameters, - List filesInput) throws IOException + Path fileParameters, + List filesInput) throws IOException { super(protocol, providerName, info, root, protocolName, fileParameters, filesInput, true, false); - _dirSequenceRoot = dirSequenceRoot; + _dirSequenceRoot = MS2PipelineManager.getSequenceDatabaseRoot(info.getContainer(), false); // Make sure a sequence file is specified. String paramDatabase = getParameters().get("pipeline, database"); @@ -152,7 +151,7 @@ public File findInputFile(String name) @Override public File findOutputFile(String name) { - // Look through all of the tasks in this pipeline + // Look through all the tasks in this pipeline for (TaskId taskId : getTaskPipeline().getTaskProgression()) { TaskFactory factory = PipelineJobService.get().getTaskFactory(taskId); @@ -216,7 +215,7 @@ public List getInteractSpectraFiles() for (TaskId taskId : getTaskPipeline().getTaskProgression()) { - TaskFactory factory = PipelineJobService.get().getTaskFactory(taskId); + TaskFactory factory = PipelineJobService.get().getTaskFactory(taskId); // Try to find one that does an MS2 search if (factory instanceof AbstractMS2SearchTaskFactory) { @@ -269,7 +268,7 @@ public File[] getSequenceFiles() arrFiles.add(MS2PipelineManager.getSequenceDBFile(_dirSequenceRoot, path)); } - return arrFiles.toArray(new File[arrFiles.size()]); + return arrFiles.toArray(new File[0]); } @Override diff --git a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineProvider.java index 930c8c2dde..fdce015539 100644 --- a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineProvider.java +++ b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchPipelineProvider.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.nio.file.Path; import java.util.List; -import java.util.Map; /** * Common base class for pipeline providers that map to MS2 searches (XTandem, Mascot, etc) @@ -66,7 +65,7 @@ public final void updateFileProperties(ViewContext context, PipeRoot pr, Pipelin public abstract void updateFilePropertiesEnabled(ViewContext context, PipeRoot pr, PipelineDirectory directory, boolean includeAll); @Override - public final @Nullable HttpView getSetupWebPart(Container container) + public final @Nullable HttpView getSetupWebPart(Container container) { if (isEnabled()) return createSetupWebPart(container); @@ -76,7 +75,7 @@ public final void updateFileProperties(ViewContext context, PipeRoot pr, Pipelin /** Called if the search provider is enabled */ @NotNull - protected abstract HttpView createSetupWebPart(Container container); + protected abstract HttpView createSetupWebPart(Container container); /** @return false if this type of search has been disabled via Spring XML config */ protected boolean isEnabled() @@ -100,7 +99,7 @@ public void initSystemDirectory(Path rootDir, Path systemDir) } @Override - public AbstractMS2SearchProtocolFactory getProtocolFactory(TaskPipeline pipeline) + public AbstractMS2SearchProtocolFactory getProtocolFactory(TaskPipeline pipeline) { // MS2 search providers all support only one protocol factory each. return getProtocolFactory(); @@ -115,34 +114,7 @@ public AbstractMS2SearchProtocolFactory getProtocolFactory(File file) return null; } - @Override - public boolean dbExists(Container container, File sequenceRoot, String db) throws IOException - { - File dbFile = FileUtil.appendName(sequenceRoot, db); - return NetworkDrive.exists(dbFile); - } - - abstract public boolean supportsDirectories(); - - abstract public boolean remembersDirectories(); - - abstract public boolean hasRemoteDirectories(); - - /** @return the list of subdirectories that might contain sequence DBs */ - @Nullable - abstract public List getSequenceDbPaths(File sequenceRoot); - /** @return the list of sequence DBs in a given directory */ @Nullable abstract public List getSequenceDbDirList(Container container, File sequenceRoot) throws IOException; - - abstract public List getTaxonomyList(Container container) throws IOException; - - /** @return enzyme name -> cut patterns - * @param container*/ - abstract public Map> getEnzymes(Container container) throws IOException; - - abstract public Map getResidue0Mods(Container container) throws IOException; - - abstract public Map getResidue1Mods(Container container); } diff --git a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocol.java b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocol.java index 5e44176028..d2dbf04e63 100644 --- a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocol.java +++ b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocol.java @@ -15,7 +15,11 @@ */ package org.labkey.ms2.pipeline; +import io.micrometer.common.util.StringUtils; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.Container; +import org.labkey.api.pipeline.ParamParser; import org.labkey.api.pipeline.PipeRoot; import org.labkey.api.pipeline.PipelineJobService; import org.labkey.api.pipeline.PipelineValidationException; @@ -27,11 +31,15 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory.SEQUENCE_FILE_SEPARATOR; + /** * AbstractMS2SearchProtocol */ @@ -39,14 +47,13 @@ abstract public class AbstractMS2SearchProtocol filesInput, - File fileParameters, + List filesInput, + Path fileParameters, @Nullable Map variableMap) throws IOException; @Override - protected void save(File file, Map addParams, Map instanceParams) throws IOException + protected void save(Path path, Map addParams, Map instanceParams) throws IOException { if (addParams == null) addParams = new HashMap<>(); - StringBuffer dbs = new StringBuffer(); - for (String dbName : _dbNames) - { - if (dbs.length() > 0) - dbs.append(';'); - dbs.append(dbName); - } - addParams.put("pipeline, database", dbs.toString()); - - super.save(file, addParams, instanceParams); + super.save(path, addParams, instanceParams); } @Override public List getInputTypes() { - TaskFactory taskFactory = PipelineJobService.get().getTaskFactory(MS2PipelineManager.MZXML_CONVERTER_TASK_ID); + TaskFactory taskFactory = PipelineJobService.get().getTaskFactory(MS2PipelineManager.MZXML_CONVERTER_TASK_ID); if (taskFactory != null) { return taskFactory.getInputTypes(); @@ -126,7 +99,25 @@ public void validate(PipeRoot root) throws PipelineValidationException { super.validate(root); - if (_dbNames.length == 0 || _dbNames[0] == null || _dbNames[0].length() == 0) + if (getDbNames().isEmpty()) + { throw new PipelineValidationException("Select a sequence database."); + } + } + + @NotNull + protected List getDbNames() + { + if (xml == null) + { + return Collections.emptyList(); + } + ParamParser parser = parse(); + String names = parser.getInputParameter(PIPELINE_DATABASE); + if (StringUtils.isEmpty(names)) + { + return Collections.emptyList(); + } + return Arrays.asList(names.split(SEQUENCE_FILE_SEPARATOR)); } } diff --git a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocolFactory.java b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocolFactory.java index ca5dadea83..f63b9248e4 100644 --- a/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocolFactory.java +++ b/ms2/src/org/labkey/ms2/pipeline/AbstractMS2SearchProtocolFactory.java @@ -15,8 +15,8 @@ */ package org.labkey.ms2.pipeline; -import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.ParamParser; import org.labkey.api.pipeline.PipeRoot; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; @@ -29,7 +29,7 @@ /** * AbstractMS2SearchProtocolFactory */ -abstract public class AbstractMS2SearchProtocolFactory extends AbstractFileAnalysisProtocolFactory +abstract public class AbstractMS2SearchProtocolFactory extends AbstractFileAnalysisProtocolFactory> { public static final String SEQUENCE_FILE_SEPARATOR = ";"; @@ -39,38 +39,16 @@ public static String[] splitSequenceFiles(String concatenatedFiles) return concatenatedFiles.split(SEQUENCE_FILE_SEPARATOR); } - public static String joinSequenceFiles(String... databases) - { - return StringUtils.join(databases, SEQUENCE_FILE_SEPARATOR); - } - @Override - protected AbstractMS2SearchProtocol createProtocolInstance(ParamParser parser) + protected AbstractMS2SearchProtocol createProtocolInstance(ParamParser parser, Container container) { - // Get the pipeline specific parameters. - String databases = parser.getInputParameter("pipeline, database"); - // Remove the parameters set in the pipeline job. parser.removeInputParameter("list path, default parameters"); parser.removeInputParameter("list path, taxonomy information"); parser.removeInputParameter("spectrum, path"); parser.removeInputParameter("output, path"); - String[] dbNames; - if (databases == null) - { - dbNames = new String[0]; - } - else - { - dbNames = splitSequenceFiles(databases); - } - - AbstractMS2SearchProtocol instance = super.createProtocolInstance(parser); - - instance.setDbNames(dbNames); - - return instance; + return super.createProtocolInstance(parser, container); } public abstract String getDefaultParametersResource(); diff --git a/ms2/src/org/labkey/ms2/pipeline/LibraProtocolFactory.java b/ms2/src/org/labkey/ms2/pipeline/LibraProtocolFactory.java index adafa0a906..0fe14193e0 100644 --- a/ms2/src/org/labkey/ms2/pipeline/LibraProtocolFactory.java +++ b/ms2/src/org/labkey/ms2/pipeline/LibraProtocolFactory.java @@ -15,6 +15,7 @@ */ package org.labkey.ms2.pipeline; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocol; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; @@ -25,7 +26,7 @@ public class LibraProtocolFactory extends AbstractFileAnalysisProtocolFactory { @Override - public AbstractFileAnalysisProtocol createProtocolInstance(String name, String description, String xml) + public AbstractFileAnalysisProtocol createProtocolInstance(String name, String description, String xml, Container container) { throw new UnsupportedOperationException(); } diff --git a/ms2/src/org/labkey/ms2/pipeline/MS2PipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/MS2PipelineProvider.java index d10e99c58a..96d4ecd10b 100644 --- a/ms2/src/org/labkey/ms2/pipeline/MS2PipelineProvider.java +++ b/ms2/src/org/labkey/ms2/pipeline/MS2PipelineProvider.java @@ -40,7 +40,7 @@ public MS2PipelineProvider(Module owningModule) } @Override - public HttpView getSetupWebPart(Container container) + public HttpView getSetupWebPart(Container container) { return new SetupWebPart(); } @@ -55,10 +55,10 @@ public void updateFileProperties(ViewContext context, PipeRoot pr, PipelineDirec String actionId = createActionId(PipelineController.UploadAction.class, "Import Search Results"); addAction(actionId, PipelineController.UploadAction.class, "Import Search Results", - directory, directory.listFiles(MS2PipelineManager.getUploadFilter()), true, true, includeAll); + directory, directory.listPaths(MS2PipelineManager.getUploadFilter()), true, true, includeAll); } - class SetupWebPart extends WebPartView + static class SetupWebPart extends WebPartView { public SetupWebPart() { diff --git a/ms2/src/org/labkey/ms2/pipeline/MS2SearchForm.java b/ms2/src/org/labkey/ms2/pipeline/MS2SearchForm.java index f2f950aab6..24ea878caf 100644 --- a/ms2/src/org/labkey/ms2/pipeline/MS2SearchForm.java +++ b/ms2/src/org/labkey/ms2/pipeline/MS2SearchForm.java @@ -15,6 +15,9 @@ */ package org.labkey.ms2.pipeline; +import java.util.Collections; +import java.util.List; + /** * MS2SearchForm */ @@ -24,20 +27,20 @@ public class MS2SearchForm extends MS2PipelineForm private String protocolName = ""; private String protocolDescription = ""; private String sequenceDBPath = ""; - private String[] sequenceDB = new String[0]; + private List sequenceDB = Collections.emptyList(); private String configureXml = ""; private boolean saveProtocol; private boolean runSearch = false; - public String[] getSequenceDB() + public List getSequenceDB() { return sequenceDB; } - public void setSequenceDB(String[] sequenceDB) + public void setSequenceDB(List sequenceDB) { - this.sequenceDB = (sequenceDB == null ? new String[0] : sequenceDB); + this.sequenceDB = (sequenceDB == null ? Collections.emptyList() : sequenceDB); } public String getConfigureXml() diff --git a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ParameterNames.java b/ms2/src/org/labkey/ms2/pipeline/ParameterNames.java similarity index 60% rename from ms2/gwtsrc/org/labkey/ms2/pipeline/client/ParameterNames.java rename to ms2/src/org/labkey/ms2/pipeline/ParameterNames.java index 9f120f7e3f..8023dee946 100644 --- a/ms2/gwtsrc/org/labkey/ms2/pipeline/client/ParameterNames.java +++ b/ms2/src/org/labkey/ms2/pipeline/ParameterNames.java @@ -1,44 +1,23 @@ -/* - * Copyright (c) 2012-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.client; - -/** - * Can't have these constants in the associated SearchFormComposite subclasses because the server can't access them, - * because GWT doesn't allow references to the UIObject class outside of the client - * User: jeckels - * Date: Jan 31, 2012 - */ -public class ParameterNames -{ - public static String STATIC_MOD = "residue, modification mass"; - public static String DYNAMIC_MOD = "residue, potential modification mass"; - /** Peptide C-terminus modifications */ - public static String DYNAMIC_C_TERM_PEPTIDE_MOD = "refine, potential C-terminus modifications"; - /** Peptide N-terminus modifications */ - public static String DYNAMIC_N_TERM_PEPTIDE_MOD = "refine, potential N-terminus modifications"; - public static String ENZYME = "protein, cleavage site"; - public static String SEQUENCE_DB = "pipeline, database"; - public static String TAXONOMY = "protein, taxon"; - - public static String MIN_PEPTIDE_PROPHET_PROBABILITY = "pipeline prophet, min probability"; - public static String MIN_PROTEIN_PROPHET_PROBABILITY = "pipeline prophet, min protein probability"; - public static final String PIPELINE_QUANT_PREFIX = "pipeline quantitation, "; - public static final String LIBRA_CONFIG_NAME_PARAM = PIPELINE_QUANT_PREFIX + "libra config name"; - public static final String LIBRA_NORMALIZATION_CHANNEL_PARAM = PIPELINE_QUANT_PREFIX + "libra normalization channel"; - public static final String QUANTITATION_ALGORITHM = PIPELINE_QUANT_PREFIX + "algorithm"; - public static final String QUANTITATION_MASS_TOLERANCE = PIPELINE_QUANT_PREFIX + "mass tolerance"; - public static final String QUANTITATION_RESIDUE_LABEL_MASS = PIPELINE_QUANT_PREFIX + "residue label mass"; -} +package org.labkey.ms2.pipeline; + +public class ParameterNames +{ + public static String STATIC_MOD = "residue, modification mass"; + public static String DYNAMIC_MOD = "residue, potential modification mass"; + /** Peptide C-terminus modifications */ + public static String DYNAMIC_C_TERM_PEPTIDE_MOD = "refine, potential C-terminus modifications"; + /** Peptide N-terminus modifications */ + public static String DYNAMIC_N_TERM_PEPTIDE_MOD = "refine, potential N-terminus modifications"; + public static String ENZYME = "protein, cleavage site"; + public static String SEQUENCE_DB = "pipeline, database"; + public static String TAXONOMY = "protein, taxon"; + + public static String MIN_PEPTIDE_PROPHET_PROBABILITY = "pipeline prophet, min probability"; + public static String MIN_PROTEIN_PROPHET_PROBABILITY = "pipeline prophet, min protein probability"; + public static final String PIPELINE_QUANT_PREFIX = "pipeline quantitation, "; + public static final String LIBRA_CONFIG_NAME_PARAM = PIPELINE_QUANT_PREFIX + "libra config name"; + public static final String LIBRA_NORMALIZATION_CHANNEL_PARAM = PIPELINE_QUANT_PREFIX + "libra normalization channel"; + public static final String QUANTITATION_ALGORITHM = PIPELINE_QUANT_PREFIX + "algorithm"; + public static final String QUANTITATION_MASS_TOLERANCE = PIPELINE_QUANT_PREFIX + "mass tolerance"; + public static final String QUANTITATION_RESIDUE_LABEL_MASS = PIPELINE_QUANT_PREFIX + "residue label mass"; +} \ No newline at end of file diff --git a/ms2/src/org/labkey/ms2/pipeline/PipelineController.java b/ms2/src/org/labkey/ms2/pipeline/PipelineController.java index 99f9f2a939..a4376ab414 100644 --- a/ms2/src/org/labkey/ms2/pipeline/PipelineController.java +++ b/ms2/src/org/labkey/ms2/pipeline/PipelineController.java @@ -15,16 +15,13 @@ */ package org.labkey.ms2.pipeline; -import org.apache.commons.lang3.StringUtils; import org.labkey.api.action.FormHandlerAction; import org.labkey.api.action.FormViewAction; -import org.labkey.api.action.GWTServiceAction; import org.labkey.api.action.LabKeyError; import org.labkey.api.action.SimpleRedirectAction; import org.labkey.api.action.SpringActionController; import org.labkey.api.data.Container; import org.labkey.api.exp.api.ExperimentService; -import org.labkey.api.gwt.server.BaseRemoteService; import org.labkey.api.pipeline.PipeRoot; import org.labkey.api.pipeline.PipelineJob; import org.labkey.api.pipeline.PipelineJobService; @@ -32,7 +29,6 @@ import org.labkey.api.pipeline.PipelineStatusFile; import org.labkey.api.pipeline.PipelineUrls; import org.labkey.api.pipeline.PipelineValidationException; -import org.labkey.api.pipeline.TaskId; import org.labkey.api.pipeline.browse.PipelinePathForm; import org.labkey.api.pipeline.file.AbstractFileAnalysisJob; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocol; @@ -46,7 +42,6 @@ import org.labkey.api.util.HelpTopic; import org.labkey.api.util.NetworkDrive; import org.labkey.api.view.ActionURL; -import org.labkey.api.view.GWTView; import org.labkey.api.view.JspView; import org.labkey.api.view.NavTree; import org.labkey.api.view.NotFoundException; @@ -55,17 +50,10 @@ import org.labkey.api.view.template.PageConfig; import org.labkey.ms2.MS2Controller; import org.labkey.ms2.MS2Manager; -import org.labkey.ms2.pipeline.client.Search; -import org.labkey.ms2.pipeline.comet.CometPipelineJob; import org.labkey.ms2.pipeline.comet.CometPipelineProvider; import org.labkey.ms2.pipeline.mascot.MascotCPipelineProvider; -import org.labkey.ms2.pipeline.mascot.MascotPipelineJob; import org.labkey.ms2.pipeline.mascot.MascotSearchTask; -import org.labkey.ms2.pipeline.rollup.FractionRollupPipelineJob; -import org.labkey.ms2.pipeline.rollup.FractionRollupPipelineProvider; -import org.labkey.ms2.pipeline.sequest.SequestPipelineJob; import org.labkey.ms2.pipeline.sequest.SequestPipelineProvider; -import org.labkey.ms2.pipeline.tandem.XTandemPipelineJob; import org.labkey.ms2.pipeline.tandem.XTandemPipelineProvider; import org.labkey.ms2.pipeline.tandem.XTandemSearchProtocolFactory; import org.springframework.validation.BindException; @@ -79,9 +67,7 @@ import java.io.IOException; import java.net.URI; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * PipelineController @@ -114,7 +100,7 @@ public ActionURL urlProjectStart(Container container) } @RequiresPermission(ReadPermission.class) - public class BeginAction extends SimpleRedirectAction + public static class BeginAction extends SimpleRedirectAction { @Override public ActionURL getRedirectURL(Object o) @@ -207,107 +193,14 @@ public ActionURL getSuccessURL(PipelinePathForm form) } } - @RequiresPermission(InsertPermission.class) - public class SearchXTandemAction extends SearchAction - { - @Override - public String getProviderName() - { - return XTandemPipelineProvider.name; - } - - @Override - protected TaskId getTaskId() - { - return new TaskId(XTandemPipelineJob.class); - } - } - - @RequiresPermission(InsertPermission.class) - public class FractionRollupAction extends SearchAction - { - @Override - public String getProviderName() - { - return FractionRollupPipelineProvider.NAME; - } - - @Override - protected TaskId getTaskId() - { - return new TaskId(FractionRollupPipelineJob.class); - } - } - - @RequiresPermission(InsertPermission.class) - public class SearchMascotAction extends SearchAction - { - @Override - public String getProviderName() - { - return MascotCPipelineProvider.name; - } - - @Override - protected TaskId getTaskId() - { - return new TaskId(MascotPipelineJob.class); - } - } - - @RequiresPermission(InsertPermission.class) - public class SearchSequestAction extends SearchAction - { - @Override - public String getProviderName() - { - return SequestPipelineProvider.name; - } - - - @Override - protected TaskId getTaskId() - { - return new TaskId(SequestPipelineJob.class); - } - } - - @RequiresPermission(InsertPermission.class) - public class SearchCometAction extends SearchAction - { - @Override - public String getProviderName() - { - return CometPipelineProvider.NAME; - } - - - @Override - protected TaskId getTaskId() - { - return new TaskId(CometPipelineJob.class); - } - } - - @RequiresPermission(ReadPermission.class) - public class SearchServiceAction extends GWTServiceAction - { - @Override - protected BaseRemoteService createService() - { - return new SearchServiceImpl(getViewContext()); - } - } - - @RequiresPermission(InsertPermission.class) public abstract class SearchAction extends FormViewAction { private PipeRoot _root; private File _dirSeqRoot; private File _dirData; - private AbstractMS2PipelineProvider _provider; - private AbstractMS2SearchProtocol _protocol; + private AbstractMS2PipelineProvider _provider; + private AbstractMS2SearchProtocol _protocol; public abstract String getProviderName(); @@ -337,7 +230,7 @@ public ModelAndView handleRequest(MS2SearchForm form, BindException errors) thro throw new NotFoundException("No path specified"); } _dirData = _root.resolvePath(form.getPath()); - if (_dirData == null || !NetworkDrive.exists(_dirData)) + if (!NetworkDrive.exists(_dirData)) throw new NotFoundException("Path does not exist " + form.getPath()); if (getProviderName() != null) @@ -354,7 +247,7 @@ public ModelAndView handleRequest(MS2SearchForm form, BindException errors) thro // If protocol is empty check for a saved protocol String protocolNameLast = PipelineService.get().getLastProtocolSetting(protocolFactory, getContainer(), getUser()); - if (protocolNameLast != null && !"".equals(protocolNameLast)) + if (protocolNameLast != null && !protocolNameLast.isEmpty()) { String[] protocolNames = protocolFactory.getProtocolNames(_root, _dirData.toPath(), false); // Make sure it is still around. @@ -369,14 +262,14 @@ else if ("".equals(form.getProtocol())) } String protocolName = form.getProtocol(); - if ( !protocolName.equals("new") && !protocolName.equals("") ) + if ( !protocolName.equals("new") && !protocolName.isEmpty()) { try { File protocolFile = protocolFactory.getParametersFile(_dirData, protocolName, _root); if (NetworkDrive.exists(protocolFile)) { - _protocol = protocolFactory.loadInstance(protocolFile); + _protocol = protocolFactory.loadInstance(protocolFile.toPath(), getContainer()); // Don't allow the instance file to override the protocol name. _protocol.setName(protocolName); @@ -388,9 +281,9 @@ else if ("".equals(form.getProtocol())) form.setProtocolName(_protocol.getName()); form.setProtocolDescription(_protocol.getDescription()); - String[] seqDbNames = _protocol.getDbNames(); + List seqDbNames = _protocol.getDbNames(); form.setConfigureXml(_protocol.getXml()); - if (seqDbNames == null || seqDbNames.length == 0) + if (seqDbNames.isEmpty()) errors.reject(ERROR_MSG, "Protocol must specify a FASTA file."); else form.setSequenceDB(seqDbNames); @@ -451,34 +344,25 @@ public boolean handlePost(MS2SearchForm form, BindException errors) throws Excep { throw new NotFoundException("Protocol '" + form.getProtocol() + "' could not be found"); } - _protocol.setDirSeqRoot(_dirSeqRoot); - _protocol.setDbPath(form.getSequenceDBPath()); - _protocol.setDbNames(form.getSequenceDB()); PipelineService.get().rememberLastProtocolSetting(_protocol.getFactory(), getContainer(), getUser(), form.getProtocol()); - PipelineService.get().rememberLastSequenceDbSetting(_protocol.getFactory(), getContainer(), - getUser(), form.getSequenceDBPath(), AbstractMS2SearchProtocolFactory.joinSequenceFiles(form.getSequenceDB())); } else { _protocol = _provider.getProtocolFactory().createProtocolInstance( form.getProtocolName(), form.getProtocolDescription(), - form.getConfigureXml()); + form.getConfigureXml(), + getContainer()); - _protocol.setDirSeqRoot(_dirSeqRoot); - _protocol.setDbPath(form.getSequenceDBPath()); - _protocol.setDbNames(form.getSequenceDB()); _protocol.setEmail(getUser().getEmail()); _protocol.validateToSave(_root, true, true); if (form.isSaveProtocol()) { _protocol.saveDefinition(_root); PipelineService.get().rememberLastProtocolSetting(_protocol.getFactory(), - getContainer(), getUser(), form.getProtocolName()); + getContainer(), getUser(), form.getProtocolName()); } - PipelineService.get().rememberLastSequenceDbSetting(_protocol.getFactory(),getContainer(), - getUser(),form.getSequenceDBPath(), AbstractMS2SearchProtocolFactory.joinSequenceFiles(form.getSequenceDB())); } if (form.getFile().length == 0) @@ -498,7 +382,7 @@ public boolean handlePost(MS2SearchForm form, BindException errors) throws Excep } AbstractMS2SearchPipelineJob job = _protocol.createPipelineJob(getViewBackgroundInfo(), _root, - mzXMLFiles, fileParameters, null); + mzXMLFiles.stream().map((f) -> f.toPath()).toList(), fileParameters.toPath(), null); // Check for existing job PipelineStatusFile existingJobStatusFile = PipelineService.get().getStatusFile(job.getLogFile()); @@ -553,7 +437,7 @@ public boolean handlePost(MS2SearchForm form, BindException errors) throws Excep } catch (PipelineValidationException e) { - errors.reject(ERROR_MSG, Search.VALIDATION_FAILURE_PREFIX + e.getMessage()); + errors.reject(ERROR_MSG, "Validation failure: " + e.getMessage()); return false; } catch (IOException e) @@ -579,32 +463,9 @@ public boolean handlePost(MS2SearchForm form, BindException errors) throws Excep @Override public ModelAndView getView(MS2SearchForm form, boolean reshow, BindException errors) { - if (!reshow || "".equals(form.getProtocol())) - form.setSaveProtocol(true); - - //get help topic - String helpTopic = getHelpTopic(_provider.getHelpTopic()).getHelpTopicHref(); - ActionURL returnURL = form.getReturnActionURL(getContainer().getStartURL(getUser())); - - form.getValidatedFiles(getContainer(), true); - - //properties to send to GWT page - Map props = new HashMap<>(); - props.put("errors", getErrors(errors)); - props.put("saveProtocol", Boolean.toString(form.isSaveProtocol())); - props.put(ActionURL.Param.returnUrl.name(), returnURL.getLocalURIString() ); - props.put("helpTopic", helpTopic); - props.put("file", StringUtils.join(form.getFile(), "/")); - props.put("searchEngine", form.getSearchEngine()); - props.put("pipelineId", getTaskId().toString()); - ActionURL targetURL = new ActionURL(getAction(), getContainer()); - props.put("targetAction", targetURL.toString()); - props.put("path", form.getPath()); - return new GWTView(org.labkey.ms2.pipeline.client.Search.class, props); + throw new UnsupportedOperationException(); } - protected abstract TaskId getTaskId(); - private String getErrors(BindException errors) { if(errors == null) return ""; @@ -641,7 +502,7 @@ public boolean handlePost(SequenceDBRootForm form, BindException errors) throws String newSequenceRoot = form.getLocalPathRoot(); URI root = null; - if (newSequenceRoot != null && newSequenceRoot.length() > 0) + if (newSequenceRoot != null && !newSequenceRoot.isEmpty()) { File file = new File(newSequenceRoot); if (!NetworkDrive.exists(file)) diff --git a/ms2/src/org/labkey/ms2/pipeline/QuantitationAlgorithm.java b/ms2/src/org/labkey/ms2/pipeline/QuantitationAlgorithm.java index bde2eda50e..32b9b3dfdb 100644 --- a/ms2/src/org/labkey/ms2/pipeline/QuantitationAlgorithm.java +++ b/ms2/src/org/labkey/ms2/pipeline/QuantitationAlgorithm.java @@ -22,7 +22,6 @@ import org.labkey.api.pipeline.WorkDirectory; import org.labkey.api.util.NetworkDrive; import org.labkey.api.util.Pair; -import org.labkey.ms2.pipeline.client.ParameterNames; import java.io.File; import java.io.FileNotFoundException; diff --git a/ms2/src/org/labkey/ms2/pipeline/SearchFormUtil.java b/ms2/src/org/labkey/ms2/pipeline/SearchFormUtil.java deleted file mode 100644 index 3691ace519..0000000000 --- a/ms2/src/org/labkey/ms2/pipeline/SearchFormUtil.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2008-2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline; - -import org.labkey.ms2.pipeline.client.CutSite; -import org.labkey.ms2.pipeline.client.Enzyme; - -import java.util.*; - -/** - * User: billnelson@uky.edu - * Date: Apr 24, 2008 - */ - -/** - * EnzymeUtil - */ -public class SearchFormUtil -{ - private static List tppEnzymeList; - private static Map mod0Map; - private static Map mod1Map; - private static Set residues; - - public static List getDefaultEnzymeList() - { - if(tppEnzymeList != null) return tppEnzymeList; - tppEnzymeList = new ArrayList<>(); - tppEnzymeList.add(new Enzyme("Trypsin",new String[]{"trypsin"}, - new CutSite[]{new CutSite( new char[]{'K','R'}, new char[]{'P'},"[KR]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Strict Trypsin",new String[]{"stricttrypsin"}, - new CutSite[]{new CutSite(new char[]{'K','R'}, new char[]{},"[KR]|[X]", false)})); - tppEnzymeList.add(new Enzyme("ArgC",new String[]{"argc", "arg-c"}, - new CutSite[]{new CutSite( new char[]{'R'}, new char[]{'P'},"[R]|{P}", false)})); - tppEnzymeList.add(new Enzyme("AspN",new String[]{"aspn","asp-n"}, - new CutSite[]{new CutSite(new char[]{'D'}, new char[]{},"[X]|[D]", true)})); - tppEnzymeList.add(new Enzyme("Chymotrypsin", new String[]{"chymotrypsin"}, - new CutSite[]{new CutSite( new char[]{'Y','W','F','M','L'}, new char[]{'P'},"[FLMWY]|{P}", false), new CutSite(new char[]{'Y','W','F','M'}, new char[]{'P'},"[YWFM]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Clostripain", new String[]{"clostripain"}, - new CutSite[]{new CutSite( new char[]{'R'}, new char[]{'-'},"[R]|[X]", false)})); - tppEnzymeList.add(new Enzyme("CNBr", new String[]{"cnbr"}, - new CutSite[]{new CutSite(new char[]{'M'}, new char[]{'P'},"[M]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Elastase", new String[]{"elastase"}, - new CutSite[]{new CutSite( new char[]{'G','V','L','I','A'}, new char[]{'P'},"[GVLIA]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Formic acid", new String[]{"formicacid","formic_acid"}, - new CutSite[]{new CutSite( new char[]{'D'}, new char[]{'P'},"[D]|{P}", false)})); - tppEnzymeList.add(new Enzyme("GluC", new String[]{"gluc"}, - new CutSite[]{new CutSite( new char[]{'D','E'}, new char[]{'P'},"[DE]|{P}", false)})); - tppEnzymeList.add(new Enzyme("GluC bicarb", new String[]{"gluc_bicarb"}, - new CutSite[]{new CutSite( new char[]{'E'}, new char[]{'P'},"[E]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Iodosobenzoate",new String[]{"iodosobenzoate"}, - new CutSite[]{new CutSite( new char[]{'W'}, new char[]{'-'},"[W]|[X]", false)})); - tppEnzymeList.add(new Enzyme("LysC", new String[]{"lysc","lys-c"}, - new CutSite[]{new CutSite( new char[]{'K'}, new char[]{'P'},"[K]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Strict LysC", new String[]{"lysc-p","lys-c/p"}, - new CutSite[]{new CutSite(new char[]{'K'}, new char[]{},"[K]|[X]", false)})); - tppEnzymeList.add(new Enzyme("LysN", new String[]{"lysn"}, - new CutSite[]{new CutSite(new char[]{'K'}, new char[]{},"[X]|[K]", true)})); - tppEnzymeList.add(new Enzyme("LysN promisc", new String[]{"lysn_promisc"}, - new CutSite[]{new CutSite(new char[]{'K','A','S','R'}, new char[]{},"[X]|[KASR]", true)})); - tppEnzymeList.add(new Enzyme("None", new String[]{"nonspecific"}, - new CutSite[]{new CutSite( new char[]{}, new char[]{},"[X]|[X]", true)})); - tppEnzymeList.add(new Enzyme("PepsinA", new String[]{"pepsina"}, - new CutSite[]{new CutSite(new char[]{'F','L'}, new char[]{'-'},"[FL]|[X]", false)})); - tppEnzymeList.add(new Enzyme("Protein endopeptidase", new String[]{"protein_endopeptidase"}, - new CutSite[]{new CutSite( new char[]{'P'}, new char[]{'-'},"[P]|[X]", false)})); - tppEnzymeList.add(new Enzyme("Staph protease", new String[]{"staph_protease"}, - new CutSite[]{new CutSite(new char[]{'E'}, new char[]{'-'},"[E]|[X]", false)})); - //Sequest cannot handle mixed sence -// tppEnzymeList.add(new Enzyme("TCA", new String[]{"tca"}, -// new CutSite[]{new CutSite( new char[]{'K','R'}, new char[]{'P'},"[KR]|{P}", false), -// new CutSite( new char[]{'Y','W','F','M'}, new char[]{'P'},"[YWFM]|{P}", false), -// new CutSite( new char[]{'D'}, new char[]{},"[X]|[D]", true)})); - tppEnzymeList.add(new Enzyme("Trypsin/CnBr", new String[]{"trypsin/cnbr","tryp-cnbr"}, - new CutSite[]{new CutSite( new char[]{'K','R'}, new char[]{'P'},"[KR]|{P}", false), - new CutSite( new char[]{'M'}, new char[]{'P'},"[M]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Trypsin/GluC", new String[]{"trypsin_gluc"}, - new CutSite[]{new CutSite(new char[]{'D','E','K','R'}, new char[]{'P'},"[DEKR]|{P}", false)})); - tppEnzymeList.add(new Enzyme("TrypsinK", new String[]{"trypsin_k"}, - new CutSite[]{new CutSite(new char[]{'K'}, new char[]{'P'},"[K]|{P}", false)})); - tppEnzymeList.add(new Enzyme("TrypsinR", new String[]{"trypsin_r"}, - new CutSite[]{new CutSite(new char[]{'R'}, new char[]{'P'},"[R]|{P}", false)})); - tppEnzymeList.add(new Enzyme("Trypsin/Chymotrypsin", new String[]{"trypsin_chymotrypsin"}, - new CutSite[]{new CutSite(new char[]{'R', 'K', 'W', 'Y', 'F'}, new char[]{'P'},"[RKWYF]|{P}", false)})); - // Not currently defined correctly in TPP; no cut is at n-term DE not c-term P -// tppEnzymeList.add(new Enzyme("Thermolysin", new String[]{"thermolysin"}, -// new CutSite[]{new CutSite(new char[]{'A','L','I','V','F','M'}, new char[]{'P'},"[ALIVFM]|{P}", true)})); - return tppEnzymeList; - } - - public static Map> getDefaultEnzymeMap() - { - Map> enzymeMap = new HashMap<>(); - - for(Enzyme enz: getDefaultEnzymeList()) - { - String name = enz.getDisplayName(); - List signatures = new ArrayList<>(); - for (CutSite site : enz.getCutSite()) - { - signatures.add(site.getSignature()); - } - enzymeMap.put(name, signatures); - } - return enzymeMap; - } - - public static Map> mascot2Tpp(List mascotEnzymeList) - { - Map> enzymeMap = new HashMap<>(); - getDefaultEnzymeList(); - for(Enzyme mascotEnz: mascotEnzymeList) - { - if(mascotEnz.getCutSite()[0].getSignature().equalsIgnoreCase("None")) - { - List values = new ArrayList<>(); - values.add(mascotEnz.getCutSite()[0].getSignature()); - enzymeMap.put("None", values); - continue; - } - for(Enzyme tppEnz: tppEnzymeList) - { - if(mascotEnz.equals(tppEnz)) - { - String displayName = tppEnz.getDisplayName(); - String signature = mascotEnz.getCutSite()[0].getSignature(); - List values = new ArrayList<>(); - values.add(signature); - enzymeMap.put(displayName, values); - } - } - } - return enzymeMap; - } - - public static Map getDefaultDynamicMods() - { - if( mod1Map == null) - { - mod1Map = new HashMap<>(); - mod1Map.put("Oxidation (15.994915@M)", "15.994915@M"); - mod1Map.put("Oxidation (15.994915@W)", "15.994915@W"); - mod1Map.put("Deamidation (0.984016@N)", "0.984016@N"); - mod1Map.put("Deamidation (0.984016@Q)", "0.984016@Q"); - mod1Map.put("Phospho (79.966331@S)","79.966331@S"); - mod1Map.put("Phospho (79.966331@T)", "79.966331@T"); - mod1Map.put("Phospho (79.966331@Y)", "79.966331@Y"); - mod1Map.put("Sulfo (79.956815@Y)", "79.956815@Y"); - mod1Map.put("Acetyl (42.010565@K)", "42.010565@K"); - mod1Map.put("Carbamyl (43.005814@N-term)", "43.005814@["); - mod1Map.put("Carbamyl (43.005814@K)","43.005814@K"); - mod1Map.put("Carbamidomethyl (57.021464@N-term)", "57.021464@["); - mod1Map.put("Carbamidomethyl (57.021464@K)", "57.021464@K"); - mod1Map.put("ICAT-D:2H(8) (8.0502@C)", "8.0502@C"); - mod1Map.put("ICAT-C:13C(9) (9.0302@C)", "9.0302@C"); - mod1Map.put("iTRAQ (144.102063@N-term,K)", "144.102063@[,144.102063@K"); - mod1Map.put("iTRAQ 8-plex (304.2@N-term,K)", "304.2@[,304.2@K"); - mod1Map.put("Label:13C(6) (6.020129@L)", "6.020129@L"); - mod1Map.put("Label:13C(6)15N(2) (8.014199@K)", "8.014199@K"); - mod1Map.put("Label:13C(6) (6.020129@R)", "6.020129@R"); - mod1Map.put("Label:2H(4) (4.025107@K)", "4.025107@K"); - mod1Map.put("Nic-h4 (-4.026655@N-term,K)", "-4.026655@[,-4.026655@K"); - mod1Map.put("Nic-d4 (4.026655@N-term,K)", "4.026655@[,4.026655@K"); - } - return mod1Map; - } - - public static Map getDefaultStaticMods() - { - if( mod0Map == null) - { - mod0Map = new HashMap<>(); - mod0Map.put("Carbamidomethyl (57.021464@C)", "57.021464@C"); - mod0Map.put("Carboxymethyl (58.005479@C)", "58.005479@C"); - mod0Map.put("ICAT-D (442.224991@C)","442.224991@C"); - mod0Map.put("ICAT-C (227.126991@C)", "227.126991@C"); - mod0Map.put("iTRAQ (144.102063@N-term,K)", "144.102063@[,144.102063@K"); - mod0Map.put("Propionamide (71.037114@C)", "71.037114@C"); - mod0Map.put("Pyridylethyl (105.057849@C)", "105.057849@C"); - mod0Map.put("Nic-h4 (105.021464@N-term,K)", "105.021464@[,105.021464@K"); - mod0Map.put("Nic-d4 (109.048119@N-term,K)", "109.048119@[,109.048119@K"); - } - return mod0Map; - } - - public static Set getValidResidues() - { - if(residues == null) - { - residues = new TreeSet<>(); - residues.add("A"); - residues.add("B"); - residues.add("C"); - residues.add("D"); - residues.add("E"); - residues.add("F"); - residues.add("G"); - residues.add("H"); - residues.add("I"); - residues.add("K"); - residues.add("L"); - residues.add("M"); - residues.add("N"); - residues.add("O"); - residues.add("P"); - residues.add("Q"); - residues.add("R"); - residues.add("S"); - residues.add("T"); - residues.add("V"); - residues.add("W"); - residues.add("X"); - residues.add("Y"); - residues.add("Z"); - } - return residues; - } -} diff --git a/ms2/src/org/labkey/ms2/pipeline/SearchServiceImpl.java b/ms2/src/org/labkey/ms2/pipeline/SearchServiceImpl.java deleted file mode 100644 index a9260b4efc..0000000000 --- a/ms2/src/org/labkey/ms2/pipeline/SearchServiceImpl.java +++ /dev/null @@ -1,541 +0,0 @@ -/* - * Copyright (c) 2008-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.ms2.pipeline; - -import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.labkey.api.data.Container; -import org.labkey.api.gwt.server.BaseRemoteService; -import org.labkey.api.pipeline.PipeRoot; -import org.labkey.api.pipeline.PipelineJob; -import org.labkey.api.pipeline.PipelineService; -import org.labkey.api.pipeline.PipelineStatusFile; -import org.labkey.api.util.FileType; -import org.labkey.api.util.NetworkDrive; -import org.labkey.api.view.NotFoundException; -import org.labkey.api.view.ViewContext; -import org.labkey.ms2.pipeline.client.GWTSearchServiceResult; -import org.labkey.ms2.pipeline.client.SearchService; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - - -/** - * User: Bill - * Date: Jan 29, 2008 - * Time: 4:04:45 PM - */ -public class SearchServiceImpl extends BaseRemoteService implements SearchService -{ - - private static Logger _log = LogManager.getLogger(SearchServiceImpl.class); - private GWTSearchServiceResult results= new GWTSearchServiceResult(); - private AbstractMS2SearchPipelineProvider provider; - private AbstractMS2SearchProtocol protocol; - - public SearchServiceImpl(ViewContext context) - { - super(context); - } - - @Override - public GWTSearchServiceResult getSearchServiceResult(String searchEngine, String path, String[] fileNames) - { - AbstractMS2PipelineProvider baseProvider = (AbstractMS2PipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - getProtocols("", baseProvider, searchEngine, path, fileNames); - if (baseProvider != null && baseProvider.isSearch()) - { - if (results.getSelectedProtocol() == null || results.getSelectedProtocol().equals("")) - getSequenceDbs(results.getDefaultSequenceDb(), searchEngine, false); - getMascotTaxonomy(searchEngine); - getEnzymes(searchEngine); - getResidueMods(searchEngine); - } - return results; - } - - private PipeRoot getPipelineRoot() - { - PipeRoot pipeRoot = PipelineService.get().findPipelineRoot(getContainer()); - if (pipeRoot == null) - { - throw new NotFoundException("No pipeline root configured for " + getContainer().getPath()); - } - return pipeRoot; - } - - private File getSequenceRoot() - { - PipeRoot pipeRoot = PipelineService.get().findPipelineRoot(getContainer()); - if (pipeRoot == null) - { - throw new NotFoundException("No pipeline root configured for " + getContainer().getPath()); - } - return MS2PipelineManager.getSequenceDatabaseRoot(pipeRoot.getContainer(), true); - } - - @Override - public GWTSearchServiceResult getProtocol(String searchEngine, String protocolName, String path, String[] fileNames) - { - AbstractMS2PipelineProvider provider = (AbstractMS2PipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - if (provider == null) - { - results.setSelectedProtocol("Loading Error"); - _log.debug("Problem loading protocols: provider equals null"); - results.appendError("Problem loading protocol: provider equals null\n"); - } - - if(protocolName == null || protocolName.length() == 0) - { - protocolName = PipelineService.get().getLastProtocolSetting(provider.getProtocolFactory(), getContainer(), - getUser()); - if(protocolName == null || protocolName.length() == 0) - protocolName = "new"; - } - if(protocolName.equals("new")) - { - results.setSelectedProtocol(""); - getMzXml(path, fileNames, false); - return results; - } - PipeRoot root = getPipelineRoot(); - - boolean protocolExists = false; - AbstractMS2SearchProtocolFactory protocolFactory = provider.getProtocolFactory(); - try - { - if(protocol == null) - { - File protocolFile = protocolFactory.getParametersFile(root.resolvePath(path), protocolName, root); - if (protocolFile != null && NetworkDrive.exists(protocolFile)) - { - protocolExists = true; - protocol = protocolFactory.loadInstance(protocolFile); - - // Don't allow the instance file to override the protocol name. - protocol.setName(protocolName); - } - else - { - protocol = protocolFactory.load(root, protocolName, false); - } - } - } - catch(IOException e) - { - results.setSelectedProtocol(""); - results.setProtocolDescription(""); - results.setProtocolXml(""); - PipelineService.get().rememberLastProtocolSetting(provider.getProtocolFactory(), getContainer(), getUser(), ""); - getMzXml(path, fileNames, false); - _log.error("Could not load " + protocolName + ".", e); - } - if (protocol != null) - { - results.setSelectedProtocol(protocolName); - if (provider.isSearch()) - { - if (protocol.getDbNames().length == 0) - { - _log.debug("Problem loading protocol: no database in protocol"); - results.appendError("Problem loading protocol: No database in protocol"); - } - - for (String dbName : protocol.getDbNames()) - { - boolean dbExists; - try - { - dbExists = provider.dbExists(getContainer(), getSequenceRoot(), dbName); - } - catch (IOException e) - { - _log.error("Unable to get DBs for " + getSequenceRoot(), e); - dbExists = false; - } - if (!dbExists) - { - results.appendError("The database " + dbName + " cannot be found."); - } - } - results.setDefaultSequenceDb(StringUtils.join(protocol.getDbNames(), ";")); - } - - PipelineService.get().rememberLastSequenceDbSetting(provider.getProtocolFactory(), getContainer(), - getUser(),"",results.getDefaultSequenceDb()); - results.setProtocolDescription(protocol.getDescription()); - results.setProtocolXml(protocol.getXml()); - } - getMzXml(path, fileNames, protocolExists); - return results; - } - - @Override - public GWTSearchServiceResult getMascotTaxonomy(String searchEngine) - { - if(provider == null) - { - provider = (AbstractMS2SearchPipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - if (provider == null) - { - results.appendError("Problem loading taxonomy: provider equals null\n"); - } - } - try - { - results.setMascotTaxonomyList(provider.getTaxonomyList(getContainer())); - } - catch(IOException e) - { - results.appendError("Trouble retrieving taxonomy list: " + e.getMessage()); - } - return results; - } - - @Override - public GWTSearchServiceResult getEnzymes(String searchEngine) - { - if(provider == null) - { - provider = (AbstractMS2SearchPipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - if (provider == null) - { - results.appendError("Problem loading enzymes: provider equals null\n"); - } - } - try - { - results.setEnzymeMap(provider.getEnzymes(getContainer())); - } - catch(IOException e) - { - results.appendError("Trouble retrieving enzyme list: " + e.getMessage()); - } - return results; - } - - public GWTSearchServiceResult getResidueMods(String searchEngine) - { - if(provider == null) - { - provider = (AbstractMS2SearchPipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - if (provider == null) - { - results.appendError("Problem loading residue modifications: provider equals null\n"); - } - } - try - { - results.setMod0Map(provider.getResidue0Mods(getContainer())); - results.setMod1Map(provider.getResidue1Mods(getContainer())); - } - catch(IOException e) - { - results.appendError("Trouble retrieving residue mods list: " + e.getMessage()); - } - return results; - - } - - private void getProtocols(String defaultProtocol, AbstractMS2PipelineProvider provider, String searchEngine, String path, String[] fileNames) - { - ArrayList protocolList = new ArrayList<>(); - if(defaultProtocol == null || defaultProtocol.length() == 0 ) - { - if(provider == null) - { - provider = (AbstractMS2PipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - } - defaultProtocol = PipelineService.get().getLastProtocolSetting(provider.getProtocolFactory(), getContainer(), - getUser()); - if(defaultProtocol == null) defaultProtocol = ""; - } - getProtocol(searchEngine, defaultProtocol, path, fileNames); - - PipeRoot root = getPipelineRoot(); - - String[] protocols = provider.getProtocolFactory().getProtocolNames(root, root.resolvePath(path).toPath(), false); - for(String protName:protocols) - { - if(!protName.equals("default")) - protocolList.add(protName); - } - results.setProtocols(protocolList); - } - - private void getSequenceDbPaths(String searchEngine, boolean refresh) - { - if(provider == null) - { - provider = (AbstractMS2SearchPipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - } - if(!provider.supportsDirectories()) return; - - List sequenceDbPaths = PipelineService.get().getLastSequenceDbPathsSetting(provider.getProtocolFactory(), - getContainer(),getUser()); - if(sequenceDbPaths == null || sequenceDbPaths.size() == 0 || refresh) - { - try - { - File dirSequenceRoot = getSequenceRoot(); - sequenceDbPaths = provider.getSequenceDbPaths(dirSequenceRoot); - if(sequenceDbPaths == null) throw new IOException("Fasta directory not found."); - if(provider.remembersDirectories()) - { - PipelineService.get().rememberLastSequenceDbPathsSetting(provider.getProtocolFactory(), - getContainer(),getUser(), sequenceDbPaths); - } - } - catch(IOException e) - { - results.appendError("There was a problem retrieving the database list from the server:\n" - + e.getMessage()); - } - } - results.setSequenceDbPaths(sequenceDbPaths); - } - - @Override - public GWTSearchServiceResult getSequenceDbs(String defaultDb, String searchEngine, boolean refresh) - { - if(defaultDb == null) defaultDb = ""; - String relativePath; - String savedRelativePath; - if(provider == null) - { - provider = (AbstractMS2SearchPipelineProvider) PipelineService.get().getPipelineProvider(searchEngine); - } - if((defaultDb.length() == 0)||(defaultDb.endsWith("/"))) - { - String savedDefaultDb = PipelineService.get().getLastSequenceDbSetting(provider.getProtocolFactory(), getContainer(), - getUser()); - if(savedDefaultDb == null ||savedDefaultDb.length() == 0) - { - savedRelativePath = defaultDb; - defaultDb = ""; - } - else - { - savedRelativePath = savedDefaultDb.substring(0, savedDefaultDb.lastIndexOf('/') + 1); - } - if(defaultDb.equals("")) - { - relativePath = savedRelativePath; - } - else - { - relativePath = defaultDb.substring(0, defaultDb.lastIndexOf('/') + 1); - } - if(relativePath.equals(savedRelativePath) && (savedDefaultDb != null && savedDefaultDb.length() != 0)) - { - defaultDb = savedDefaultDb; - } - else - { - defaultDb = relativePath; - } - } - else - { - relativePath = defaultDb.substring(0, defaultDb.lastIndexOf('/') + 1); - } - return getSequenceDbs(relativePath, defaultDb, searchEngine, refresh); - } - - private GWTSearchServiceResult getSequenceDbs(String relativePath, String defaultDb, String searchEngine, boolean refresh) - { - List sequenceDbs = null; - String defaultDbPath; - List returnList = new ArrayList<>(); - if(defaultDb != null && defaultDb.endsWith("/")) - { - String savedDb = - PipelineService.get().getLastSequenceDbSetting(provider.getProtocolFactory(),getContainer(),getUser()); - if(savedDb != null && savedDb.length() > 0) - { - if(defaultDb.equals("/") && (!savedDb.contains("/") || savedDb.indexOf("/") == 0 ) ) - { - defaultDb = savedDb; - } - else if(savedDb.contains("/") && defaultDb.indexOf("/") != 0) - { - String test = savedDb.replaceFirst(defaultDb, ""); - if(!test.contains("/")) defaultDb = savedDb; - } - } - } - getSequenceDbPaths(searchEngine, refresh); - - if(relativePath.equals("/")) - { - defaultDbPath = getSequenceRoot().toURI().getPath(); - } - else - { - defaultDbPath = getSequenceRoot().toURI().getPath() + relativePath; - } - URI defaultDbPathURI; - try - { - if(provider.hasRemoteDirectories()) - { - relativePath = relativePath.replaceAll(" ","%20"); - URI uriPath = new URI(relativePath); - sequenceDbs = provider.getSequenceDbDirList(getContainer(), new File(uriPath)); - } - else - { - defaultDbPathURI = new File(defaultDbPath).toURI(); - sequenceDbs = provider.getSequenceDbDirList(getContainer(), new File(defaultDbPathURI)); - } - if(sequenceDbs == null) - { - results.appendError("Could not find the default sequence database path : " + defaultDbPath); - defaultDbPathURI = getSequenceRoot().toURI(); - sequenceDbs = provider.getSequenceDbDirList(getContainer(), new File(defaultDbPathURI)); - } - else - { - results.setDefaultSequenceDb(defaultDb); - } - } - catch(URISyntaxException e) - { - results.appendError("There was a problem parsing the database database path:\n" - + e.getMessage()); - results.setSequenceDbs(sequenceDbs, relativePath); - return results; - } - catch(IOException e) - { - results.appendError("There was a problem retrieving the database list from the server:\n" - + e.getMessage()); - results.setSequenceDbs(sequenceDbs, relativePath); - return results; - } - - if(sequenceDbs == null || sequenceDbs.size() == 0 ) - { - sequenceDbs = new ArrayList<>(); - sequenceDbs.add("None found."); - results.setSequenceDbs(sequenceDbs, relativePath); - return results; - } - - for(String db:sequenceDbs) - { - if(!db.endsWith("/")) - { - returnList.add(db); - } - } - - if(returnList.size() == 0 ) - { - returnList = new ArrayList<>(); - returnList.add("None found."); - } - results.setSequenceDbs(returnList, relativePath); - return results; - } - - private void getMzXml(String path, String[] fileNames, boolean protocolExists) - { - if (protocol == null) - protocolExists = false; - - PipeRoot pr; - try - { - Container c = getContainer(); - pr = PipelineService.get().findPipelineRoot(c); - if (pr == null || !pr.isValid()) - throw new IOException("Can't find root directory."); - - File dirData = pr.resolvePath(path); - File dirAnalysis = null; - if (protocol != null) - dirAnalysis = protocol.getAnalysisDir(dirData, pr); - - results.setActiveJobs(false); - results.setFileInputNames(new ArrayList<>()); - results.setFileInputStatus(new ArrayList<>()); - - Arrays.sort(fileNames, String.CASE_INSENSITIVE_ORDER); - for (String name : fileNames) - { - if (name == null || StringUtils.containsAny(name, "..", "/", "\\")) - { - results.appendError("Invalid file name " + name); - } - else - { - results.getFileInputNames().add(name); - if (protocolExists) - results.getFileInputStatus().add(getInputStatus(protocol, dirData, dirAnalysis, name, true)); - } - } - if (protocolExists) - results.getFileInputStatus().add(getInputStatus(protocol, dirData, dirAnalysis, null, false)); - } - catch (IOException e) - { - results.appendError(e.getMessage()); - } - } - - private String getInputStatus(AbstractMS2SearchProtocol protocol, File dirData, File dirAnalysis, - String fileInputName, boolean statusSingle) - { - File fileStatus = null; - - if (!statusSingle) - { - fileStatus = PipelineJob.FT_LOG.newFile(dirAnalysis, - protocol.getJoinedBaseName()); - } - else if (fileInputName != null) - { - File fileInput = new File(dirData, fileInputName); - FileType ft = protocol.findInputType(fileInput); - if (ft != null) - fileStatus = PipelineJob.FT_LOG.newFile(dirAnalysis, ft.getBaseName(fileInput)); - } - - if (fileStatus != null) - { - PipelineStatusFile sf = PipelineService.get().getStatusFile(fileStatus); - if (sf == null) - return null; - - if (sf.isActive()) - results.setActiveJobs(true); - return sf.getStatus(); - } - - // Failed to get status. Assume job is active, and return unknown status. - results.setActiveJobs(true); - return "UNKNOWN"; - } -} diff --git a/ms2/src/org/labkey/ms2/pipeline/TPPTask.java b/ms2/src/org/labkey/ms2/pipeline/TPPTask.java index 972644d738..ca627b327f 100644 --- a/ms2/src/org/labkey/ms2/pipeline/TPPTask.java +++ b/ms2/src/org/labkey/ms2/pipeline/TPPTask.java @@ -38,7 +38,6 @@ import org.labkey.api.util.Pair; import org.labkey.api.util.PepXMLFileType; import org.labkey.api.util.ProtXMLFileType; -import org.labkey.ms2.pipeline.client.ParameterNames; import java.io.File; import java.io.FileNotFoundException; diff --git a/ms2/src/org/labkey/ms2/pipeline/comet/Comet2014ParamsBuilder.java b/ms2/src/org/labkey/ms2/pipeline/comet/Comet2014ParamsBuilder.java index e2a29043ca..5be54bbe18 100644 --- a/ms2/src/org/labkey/ms2/pipeline/comet/Comet2014ParamsBuilder.java +++ b/ms2/src/org/labkey/ms2/pipeline/comet/Comet2014ParamsBuilder.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.ms2.pipeline.AbstractMS2SearchTask; -import org.labkey.ms2.pipeline.client.ParameterNames; +import org.labkey.ms2.pipeline.ParameterNames; import org.labkey.ms2.pipeline.sequest.AbstractSequestParams; import org.labkey.ms2.pipeline.sequest.BooleanParamsValidator; import org.labkey.ms2.pipeline.sequest.ConverterFactory; diff --git a/ms2/src/org/labkey/ms2/pipeline/comet/Comet2015ParamsBuilder.java b/ms2/src/org/labkey/ms2/pipeline/comet/Comet2015ParamsBuilder.java index 4295c0b6a9..1535ee2824 100644 --- a/ms2/src/org/labkey/ms2/pipeline/comet/Comet2015ParamsBuilder.java +++ b/ms2/src/org/labkey/ms2/pipeline/comet/Comet2015ParamsBuilder.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.ms2.pipeline.AbstractMS2SearchTask; -import org.labkey.ms2.pipeline.client.ParameterNames; +import org.labkey.ms2.pipeline.ParameterNames; import org.labkey.ms2.pipeline.sequest.AbstractSequestParams; import org.labkey.ms2.pipeline.sequest.BooleanParamsValidator; import org.labkey.ms2.pipeline.sequest.ConverterFactory; diff --git a/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineJob.java b/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineJob.java index d391031f19..dc681db3d2 100644 --- a/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineJob.java +++ b/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineJob.java @@ -27,6 +27,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; /** @@ -35,7 +36,7 @@ */ public class CometPipelineJob extends AbstractMS2SearchPipelineJob { - private static final TaskId TASK_ID = new TaskId(CometPipelineJob.class); + public static final TaskId TASK_ID = new TaskId(CometPipelineJob.class); @JsonCreator protected CometPipelineJob(@JsonProperty("_dirSequenceRoot") File dirSequenceRoot) @@ -47,12 +48,11 @@ public CometPipelineJob(CometSearchProtocol protocol, ViewBackgroundInfo info, PipeRoot root, String name, - File dirSequenceRoot, - List filesMzXML, - File fileInputXML + List filesMzXML, + Path fileInputXML ) throws IOException { - super(protocol, SequestPipelineProvider.name, info, root, name, dirSequenceRoot, fileInputXML, filesMzXML); + super(protocol, SequestPipelineProvider.name, info, root, name, fileInputXML, filesMzXML); header("Comet search for " + getBaseName()); writeInputFilesToLog(); diff --git a/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineProvider.java index 00c4f1ebd5..ad8d42135f 100644 --- a/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineProvider.java +++ b/ms2/src/org/labkey/ms2/pipeline/comet/CometPipelineProvider.java @@ -31,14 +31,11 @@ import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; import org.labkey.ms2.pipeline.MS2PipelineManager; import org.labkey.ms2.pipeline.PipelineController; -import org.labkey.ms2.pipeline.SearchFormUtil; import java.io.File; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; /** * User: jeckels @@ -64,9 +61,16 @@ public boolean isStatusViewableFile(Container container, String name, String bas @Override public void updateFilePropertiesEnabled(ViewContext context, PipeRoot pr, PipelineDirectory directory, boolean includeAll) { - String actionId = createActionId(PipelineController.SearchCometAction.class, ACTION_LABEL); - addAction(actionId, PipelineController.SearchCometAction.class, ACTION_LABEL, - directory, directory.listFiles(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + String actionId = getActionId(); + addAction(actionId, getTaskPipeline(CometPipelineJob.TASK_ID).getAnalyzeURL(context.getContainer(), directory.getRelativePath(), null), ACTION_LABEL, + directory, directory.listPaths(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + } + + @Override + protected String getActionId() + { + // Retain old GWT action class as the action ID to preserve file browser button configuration + return createActionId("org.labkey.ms2.pipeline.PipelineController$SearchCometAction", ACTION_LABEL); } @Override @@ -74,7 +78,7 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C { if (isEnabled()) { - String actionId = createActionId(PipelineController.SearchCometAction.class, ACTION_LABEL); + String actionId = getActionId(); return Collections.singletonList(new PipelineActionConfig(actionId, PipelineActionConfig.displayState.toolbar, ACTION_LABEL, true)); } return super.getDefaultActionConfigSkipModuleEnabledCheck(container); @@ -82,12 +86,12 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C @Override @NotNull - public HttpView createSetupWebPart(Container container) + public HttpView createSetupWebPart(Container container) { return new SetupWebPart(); } - static class SetupWebPart extends WebPartView + static class SetupWebPart extends WebPartView { public SetupWebPart() { @@ -116,43 +120,12 @@ public AbstractMS2SearchProtocolFactory getProtocolFactory() return CometSearchProtocolFactory.get(); } - @Override - public List getSequenceDbPaths(File sequenceRoot) - { - return MS2PipelineManager.addSequenceDbPaths(sequenceRoot, "", new ArrayList<>()); - } - @Override public List getSequenceDbDirList(Container container, File sequenceRoot) { return MS2PipelineManager.getSequenceDirList(sequenceRoot, ""); } - @Override - public List getTaxonomyList(Container container) - { - //Comet does not support Mascot style taxonomy. - return null; - } - - @Override - public Map> getEnzymes(Container container) - { - return SearchFormUtil.getDefaultEnzymeMap(); - } - - @Override - public Map getResidue0Mods(Container container) - { - return SearchFormUtil.getDefaultStaticMods(); - } - - @Override - public Map getResidue1Mods(Container container) - { - return SearchFormUtil.getDefaultDynamicMods(); - } - @Override public String getHelpTopic() { @@ -163,23 +136,4 @@ public String getHelpTopic() public void ensureEnabled(Container container) { } - - @Override - public boolean supportsDirectories() - { - return true; - } - - @Override - public boolean remembersDirectories() - { - return false; - } - - @Override - public boolean hasRemoteDirectories() - { - return false; - } - } diff --git a/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocol.java b/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocol.java index 427ffa8342..3ac389d93c 100644 --- a/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocol.java +++ b/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocol.java @@ -16,6 +16,7 @@ package org.labkey.ms2.pipeline.comet; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.PipeRoot; import org.labkey.api.pipeline.PipelineValidationException; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; @@ -25,6 +26,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; import java.util.Map; @@ -34,9 +36,9 @@ */ public class CometSearchProtocol extends AbstractMS2SearchProtocol { - public CometSearchProtocol(String name, String description, String xml) + public CometSearchProtocol(String name, String description, String xml, Container container) { - super(name, description, xml); + super(name, description, xml, container); } @Override @@ -47,24 +49,24 @@ public AbstractFileAnalysisProtocolFactory getFactory() @Override public CometPipelineJob createPipelineJob(ViewBackgroundInfo info, - PipeRoot root, List filesInput, - File fileParameters, @Nullable Map variableMap + PipeRoot root, List filesInput, + Path fileParameters, @Nullable Map variableMap ) throws IOException { - return new CometPipelineJob(this, info, root, getName(), getDirSeqRoot(), + return new CometPipelineJob(this, info, root, getName(), filesInput, fileParameters); } @Override public void validate(PipeRoot root) throws PipelineValidationException { - String[] dbNames = getDbNames(); - if(dbNames == null || dbNames.length == 0) + List dbNames = getDbNames(); + if(dbNames.isEmpty()) throw new IllegalArgumentException("A sequence database must be selected."); - File fileSequenceDB = FileUtil.appendName(getDirSeqRoot(), dbNames[0]); + File fileSequenceDB = FileUtil.appendName(getDirSeqRoot(), dbNames.get(0)); if (!fileSequenceDB.exists()) - throw new IllegalArgumentException("Sequence database '" + dbNames[0] + "' is not found in local FASTA root."); + throw new IllegalArgumentException("Sequence database '" + dbNames.get(0) + "' is not found in local FASTA root."); super.validate(root); } diff --git a/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocolFactory.java b/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocolFactory.java index 8b76cb7255..6f7d1d2752 100644 --- a/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocolFactory.java +++ b/ms2/src/org/labkey/ms2/pipeline/comet/CometSearchProtocolFactory.java @@ -15,6 +15,7 @@ */ package org.labkey.ms2.pipeline.comet; +import org.labkey.api.data.Container; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; @@ -49,8 +50,8 @@ public String getDefaultParametersResource() } @Override - public AbstractMS2SearchProtocol createProtocolInstance(String name, String description, String xml) + public CometSearchProtocol createProtocolInstance(String name, String description, String xml, Container container) { - return new CometSearchProtocol(name, description, xml); + return new CometSearchProtocol(name, description, xml, container); } } diff --git a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotCPipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotCPipelineProvider.java index fcf20552a4..b8824be1de 100644 --- a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotCPipelineProvider.java +++ b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotCPipelineProvider.java @@ -16,7 +16,6 @@ package org.labkey.ms2.pipeline.mascot; import org.jetbrains.annotations.NotNull; -import org.labkey.api.collections.CaseInsensitiveHashSet; import org.labkey.api.data.Container; import org.labkey.api.module.Module; import org.labkey.api.pipeline.PipeRoot; @@ -39,7 +38,6 @@ import java.io.PrintWriter; import java.util.Collections; import java.util.List; -import java.util.Map; /** * MascotCPipelineProvider class @@ -73,9 +71,16 @@ public void updateFilePropertiesEnabled(ViewContext context, PipeRoot pr, Pipeli if (!MascotConfig.findMascotConfig(context.getContainer()).hasMascotServer()) return; - String actionId = createActionId(PipelineController.SearchMascotAction.class, ACTION_LABEL); - addAction(actionId, PipelineController.SearchMascotAction.class, ACTION_LABEL, - directory, directory.listFiles(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + String actionId = getActionId(); + addAction(actionId, getTaskPipeline(MascotPipelineJob.TASK_ID).getAnalyzeURL(context.getContainer(), null, null), ACTION_LABEL, + directory, directory.listPaths(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + } + + @Override + protected String getActionId() + { + // Retain old GWT action class as the action ID to preserve file browser button configuration + return createActionId("org.labkey.ms2.pipeline.PipelineController$SearchMascotAction", ACTION_LABEL); } @Override @@ -83,7 +88,7 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C { if (isEnabled() && MascotConfig.findMascotConfig(container).hasMascotServer()) { - String actionId = createActionId(PipelineController.SearchMascotAction.class, ACTION_LABEL); + String actionId = getActionId(); return Collections.singletonList(new PipelineActionConfig(actionId, PipelineActionConfig.displayState.toolbar, ACTION_LABEL, true)); } return super.getDefaultActionConfigSkipModuleEnabledCheck(container); @@ -91,12 +96,12 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C @Override @NotNull - public HttpView createSetupWebPart(Container container) + public HttpView createSetupWebPart(Container container) { return new SetupWebPart(); } - private static class SetupWebPart extends WebPartView + private static class SetupWebPart extends WebPartView { public SetupWebPart() { @@ -130,18 +135,6 @@ public AbstractMS2SearchProtocolFactory getProtocolFactory() return MascotSearchProtocolFactory.get(); } - @Override - public List getSequenceDbPaths(File sequenceRoot) - { - return null;//No directories for Mascot databases. - } - - @Override - public boolean dbExists(Container container, File sequenceRoot, String db) throws IOException - { - return new CaseInsensitiveHashSet(getSequenceDbDirList(container, sequenceRoot)).contains(db); - } - @Override public List getSequenceDbDirList(Container container, File sequenceRoot) throws IOException { @@ -151,7 +144,7 @@ public List getSequenceDbDirList(Container container, File sequenceRoot) mascotClient.setProxyURL(config.getMascotHTTPProxy()); List sequenceDBs = mascotClient.getSequenceDbList(); - if (0 == sequenceDBs.size()) + if (sequenceDBs.isEmpty()) { // TODO: Would be nice if the Mascot client just threw its own connectivity exception. String connectivityResult = mascotClient.testConnectivity(false); @@ -161,103 +154,6 @@ public List getSequenceDbDirList(Container container, File sequenceRoot) return sequenceDBs; } - @Override - public List getTaxonomyList(Container container) throws IOException - { - MascotConfig config = ensureMascotConfig(container); - - MascotClientImpl mascotClient = new MascotClientImpl(config.getMascotServer(), null); - mascotClient.setProxyURL(config.getMascotHTTPProxy()); - List taxonomy = mascotClient.getTaxonomyList(); - - if (0 == taxonomy.size()) - { - // TODO: Would be nice if the Mascot client just threw its own connectivity exception. - String connectivityResult = mascotClient.testConnectivity(false); - if (!"".equals(connectivityResult)) - throw new IOException(connectivityResult); - } - return taxonomy; -// ArrayList mock = new ArrayList(); -// mock.add("All entries"); -// mock.add(". . Archaea (Archaeobacteria)"); -// mock.add(". . Eukaryota (eucaryotes)"); -// mock.add(". . . . Alveolata (alveolates)"); -// mock.add(". . . . . . Plasmodium falciparum (malaria parasite)"); -// mock.add(". . . . . . Other Alveolata"); -// mock.add(". . . . Metazoa (Animals)"); -// mock.add(". . . . . . Caenorhabditis elegans"); -// mock.add(". . . . . . Drosophila (fruit flies)"); -// mock.add(". . . . . . Chordata (vertebrates and relatives)"); -// mock.add(". . . . . . . . bony vertebrates"); -// mock.add(". . . . . . . . . . lobe-finned fish and tetrapod clade"); -// mock.add(". . . . . . . . . . . . Mammalia (mammals)"); -// mock.add(". . . . . . . . . . . . . . Primates"); -// mock.add(". . . . . . . . . . . . . . . . Homo sapiens (human)"); -// mock.add(". . . . . . . . . . . . . . . . Other primates"); -// mock.add(". . . . . . . . . . . . . . Rodentia (Rodents)"); -// mock.add(". . . . . . . . . . . . . . . . Mus."); -// mock.add(". . . . . . . . . . . . . . . . . . Mus musculus (house mouse)"); -// mock.add(". . . . . . . . . . . . . . . . Rattus"); -// mock.add(". . . . . . . . . . . . . . . . Other rodentia"); -// mock.add(". . . . . . . . . . . . . . Other mammalia"); -// mock.add(". . . . . . . . . . . . Xenopus laevis (African clawed frog)"); -// mock.add(". . . . . . . . . . . . Other lobe-finned fish and tetrapod clade"); -// mock.add(". . . . . . . . . . Actinopterygii (ray-finned fishes)"); -// mock.add(". . . . . . . . . . . . Fugu rubripes (Japanese Pufferfish)"); -// mock.add(". . . . . . . . . . . . Danio rerio (zebra fish)"); -// mock.add(". . . . . . . . . . . . Other Actinopterygii"); -// mock.add(". . . . . . . . . . Other bony vertebrates"); -// mock.add(". . . . . . . . Other Chordata"); -// mock.add(". . . . . . Other Metazoa"); -// mock.add(". . . . Dictyostelium discoideum"); -// mock.add(". . . . Fungi"); -// mock.add(". . . . . . Saccharomyces Cerevisiae (baker's yeast)"); -// mock.add(". . . . . . Schizosaccharomyces pombe (fission yeast)"); -// mock.add(". . . . . . Pneumocystis carinii"); -// mock.add(". . . . . . Other Fungi"); -// mock.add(". . . . Viridiplantae (Green Plants)"); -// mock.add(". . . . . . Arabidopsis thaliana (thale cress)"); -// mock.add(". . . . . . Oryza sativa (rice)"); -// mock.add(". . . . . . Other green plants"); -// mock.add(". . . . Other Eukaryota"); -// mock.add(". . Bacteria (Eubacteria)"); -// mock.add(". . . . Proteobacteria (purple bacteria)"); -// mock.add(". . . . . . Escherichia coli"); -// mock.add(". . . . . . Campylobacter jejuni"); -// mock.add(". . . . . . Other Proteobacteria"); -// mock.add(". . . . Firmicutes (gram-positive bacteria)"); -// mock.add(". . . . . . Mycoplasma"); -// mock.add(". . . . . . Bacillus subtilis"); -// mock.add(". . . . . . Streptococcus Pneumoniae"); -// mock.add(". . . . . . Streptomyces coelicolor"); -// mock.add(". . . . . . Other Firmicutes"); -// mock.add(". . . . Other Bacteria"); -// mock.add(". . Viruses"); -// mock.add(". . . . Hepatitis C virus"); -// mock.add(". . . . Other viruses"); -// mock.add(". . Other (includes plasmids and artificial sequences)"); -// mock.add(". . unclassified"); -// mock.add(". . Species information unavailable"); -// return mock; - } - - @Override - public Map> getEnzymes(Container container) throws IOException - { - MascotConfig config = ensureMascotConfig(container); - - MascotClientImpl mascotClient = new MascotClientImpl(config.getMascotServer(), null); - mascotClient.setProxyURL(config.getMascotHTTPProxy()); - Map> enzymes = mascotClient.getEnzymeMap(); - - if (0 == enzymes.size()) - { - throw new IOException("Could not find any enzymes, perhaps labkeydbmgmt.pl is out of date?"); - } - return enzymes; - } - @NotNull private MascotConfig ensureMascotConfig(Container container) throws IOException { @@ -266,61 +162,18 @@ private MascotConfig ensureMascotConfig(Container container) throws IOException throw new IOException("Mascot Server has not been configured."); return config; } - - @Override - public Map getResidue0Mods(Container container) throws IOException - { - MascotConfig config = ensureMascotConfig(container); - - MascotClientImpl mascotClient = new MascotClientImpl(config.getMascotServer(), null); - mascotClient.setProxyURL(config.getMascotHTTPProxy()); - Map mods = mascotClient.getResidueModsMap(); - - if (0 == mods.size()) - { - String connectivityResult = mascotClient.testConnectivity(false); - if (!"".equals(connectivityResult)) - throw new IOException(connectivityResult); - } - return mods; - } - - @Override - public Map getResidue1Mods(Container container) - { - return null; //no difference between static and dynamic mods in mascot - } - @Override public String getHelpTopic() { return "pipelineMascot"; } - @Override - public boolean supportsDirectories() - { - return false; - } - - @Override - public boolean remembersDirectories() - { - return false; - } - - @Override - public boolean hasRemoteDirectories() - { - return false; - } - @Override public void ensureEnabled(Container container) throws PipelineValidationException { MascotConfig config = MascotConfig.findMascotConfig(container); String mascotServer = config.getMascotServer(); - if ((!config.hasMascotServer() || 0==mascotServer.length())) + if ((!config.hasMascotServer() || mascotServer.isEmpty())) throw new PipelineValidationException("Mascot server has not been specified in site customization."); } } diff --git a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotClientImpl.java b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotClientImpl.java index 36e4a0ce6b..7aa90ce0d4 100644 --- a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotClientImpl.java +++ b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotClientImpl.java @@ -41,9 +41,6 @@ import org.labkey.api.view.ActionURL; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; import org.labkey.ms2.pipeline.AbstractMS2SearchTask; -import org.labkey.ms2.pipeline.SearchFormUtil; -import org.labkey.ms2.pipeline.client.CutSite; -import org.labkey.ms2.pipeline.client.Enzyme; import java.io.BufferedInputStream; import java.io.BufferedReader; @@ -789,77 +786,6 @@ public Map getResidueModsMap() return mods; } - public Map> getEnzymeMap() - { - errorCode = 0; - errorString = ""; - - findWorkableSettings (false); - - Properties results; - Properties parameters = new Properties(); - parameters.setProperty("cgi", "labkeydbmgmt.pl"); - parameters.setProperty("cmd", "getenzymes"); - - results = request(parameters, false); - - List enzymes = new ArrayList<>(); - String dbsString = results.getProperty("HTTPContent", ""); - String[] contentLines = dbsString.split("\n"); - String mascotName = ""; - char[] cuts = null; - char[] noCuts = new char[0]; - boolean nTerm = false; - - for (String contentLine : contentLines) - { - contentLine = contentLine.trim(); - - if(contentLine.startsWith("Title")) - { - mascotName = contentLine.substring(contentLine.indexOf(":") +1); - } - else if(contentLine.startsWith("Cleavage")) - { - String cutString = contentLine.substring(contentLine.indexOf(":")+1); - int numCuts = cutString.length(); - cuts = new char[numCuts]; - for(int i = 0; i < numCuts; i++) - { - cuts[i] = cutString.charAt(i); - } - } - else if(contentLine.startsWith("Restrict")) - { - String noCutString = contentLine.substring(contentLine.indexOf(":")+1); - int numNoCuts = noCutString.length(); - noCuts = new char[numNoCuts]; - for(int i = 0; i < numNoCuts; i++) - { - noCuts[i] = noCutString.charAt(i); - } - } - else if(contentLine.equals("Cterm")) - { - nTerm = false; - } - else if(contentLine.equals("Nterm")) - { - nTerm = true; - } - else if(contentLine.equals("*")) - { - CutSite[] cutSites = new CutSite[1]; - cutSites[0] = new CutSite(cuts,noCuts,mascotName,nTerm); - Enzyme enzyme = new Enzyme(mascotName,null, cutSites); - enzymes.add(enzyme); - noCuts = new char[0]; - } - } - return SearchFormUtil.mascot2Tpp(enzymes); - - } - public int search (String paramFile, String queryFile, String resultFile) { errorCode = 0; @@ -1154,7 +1080,7 @@ protected boolean submitFile (String sessionID, String taskID, // Decoy controlled by "mascot, decoy", submitted as "1" or nothing at all String decoyValue = parser.getInputParameter("mascot, decoy"); - if (decoyValue != null && ((Boolean)new BooleanConverter().convert(Boolean.class, decoyValue)).booleanValue()) + if (decoyValue != null && new BooleanConverter().convert(Boolean.class, decoyValue).booleanValue()) { parts.put("DECOY", "1"); } @@ -1232,7 +1158,7 @@ protected boolean submitFile (String sessionID, String taskID, { getLogger().error("Failed to get response from Mascot query '" + mascotRequestURL + "' for " + queryFile.getPath() + " with parameters " + queryParamFile.getPath() + " on attempt#" + - (attempt + 1) + ".\n" + "Mascot output: " + sb.toString()); + (attempt + 1) + ".\n" + "Mascot output: " + sb); } } catch (IOException err) @@ -1449,7 +1375,7 @@ private Properties request(Properties parameters, boolean parse) catch (Exception x) { String password = parameters.getProperty("password",""); - if (password.length() >0) + if (!password.isEmpty()) mascotRequestURL = mascotRequestURL.replace(password, "***"); // If using the class logger, then assume user interface will deliver the error message. String msg = "Connect("+_url+","+parameters.getProperty("username","")+"," @@ -1496,10 +1422,10 @@ private InputStream getRequestResultStream (Properties parameters) catch (MalformedURLException x) { String password = parameters.getProperty("password",""); - if (password.length() >0) + if (!password.isEmpty()) mascotRequestURL = mascotRequestURL.replace(password, "***"); getLogger().warn("Exception "+x.getClass()+" connect("+_url+","+parameters.getProperty("username","")+"," - +(parameters.getProperty("password","").length()>0 ? "***" : "") + +(!parameters.getProperty("password", "").isEmpty() ? "***" : "") +","+_proxyURL+")="+mascotRequestURL, x); //Fail to parse Mascot Server URL errorCode = 1; @@ -1507,10 +1433,10 @@ private InputStream getRequestResultStream (Properties parameters) catch (Exception x) { String password = parameters.getProperty("password",""); - if (password.length() >0) + if (!password.isEmpty()) mascotRequestURL = mascotRequestURL.replace(password, "***"); getLogger().warn("Exception "+x.getClass()+" on connect("+_url+","+parameters.getProperty("username","")+"," - +(parameters.getProperty("password","").length()>0 ? "***" : "") + +(!parameters.getProperty("password", "").isEmpty() ? "***" : "") +","+_proxyURL+")="+mascotRequestURL, x); //Fail to interact with Mascot Server errorCode = 2; diff --git a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotPipelineJob.java b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotPipelineJob.java index 8e5aeba786..a85df4dd45 100644 --- a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotPipelineJob.java +++ b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotPipelineJob.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; /** @@ -36,7 +37,7 @@ */ public class MascotPipelineJob extends AbstractMS2SearchPipelineJob implements MascotSearchTask.JobSupport { - private static final TaskId TASK_ID = new TaskId(MascotPipelineJob.class); + public static final TaskId TASK_ID = new TaskId(MascotPipelineJob.class); private String _mascotServer; private String _mascotHTTPProxy; @@ -53,11 +54,10 @@ public MascotPipelineJob(MascotSearchProtocol protocol, ViewBackgroundInfo info, PipeRoot root, String name, - File dirSequenceRoot, - List filesMzXML, - File fileInputXML) throws IOException + List filesMzXML, + Path fileInputXML) throws IOException { - super(protocol, MascotCPipelineProvider.name, info, root, name, dirSequenceRoot, fileInputXML, filesMzXML); + super(protocol, MascotCPipelineProvider.name, info, root, name, fileInputXML, filesMzXML); MascotConfig config = MascotConfig.findMascotConfig(info.getContainer()); _mascotServer = config.getMascotServer(); diff --git a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocol.java b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocol.java index 665196ca66..86906aae09 100644 --- a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocol.java +++ b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocol.java @@ -16,13 +16,14 @@ package org.labkey.ms2.pipeline.mascot; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.PipeRoot; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; import org.labkey.api.view.ViewBackgroundInfo; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; -import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; import java.util.Map; @@ -32,9 +33,9 @@ */ public class MascotSearchProtocol extends AbstractMS2SearchProtocol { - public MascotSearchProtocol(String name, String description, String xml) + public MascotSearchProtocol(String name, String description, String xml, Container container) { - super(name, description, xml); + super(name, description, xml, container); } @Override @@ -45,11 +46,11 @@ public AbstractFileAnalysisProtocolFactory getFactory() @Override public MascotPipelineJob createPipelineJob(ViewBackgroundInfo info, - PipeRoot root, List filesInput, - File fileParameters, @Nullable Map variableMap + PipeRoot root, List filesInput, + Path fileParameters, @Nullable Map variableMap ) throws IOException { - return new MascotPipelineJob(this, info, root, getName(), getDirSeqRoot(), + return new MascotPipelineJob(this, info, root, getName(), filesInput, fileParameters); } } diff --git a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocolFactory.java b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocolFactory.java index ca230a7a03..fd51b368da 100644 --- a/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocolFactory.java +++ b/ms2/src/org/labkey/ms2/pipeline/mascot/MascotSearchProtocolFactory.java @@ -15,6 +15,7 @@ */ package org.labkey.ms2.pipeline.mascot; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.ParamParser; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; @@ -50,17 +51,17 @@ public String getDefaultParametersResource() } @Override - public MascotSearchProtocol createProtocolInstance(String name, String description, String xml) + public MascotSearchProtocol createProtocolInstance(String name, String description, String xml, Container container) { - return new MascotSearchProtocol(name, description, xml); + return new MascotSearchProtocol(name, description, xml, container); } @Override - protected AbstractMS2SearchProtocol createProtocolInstance(ParamParser parser) + protected AbstractMS2SearchProtocol createProtocolInstance(ParamParser parser, Container container) { parser.removeInputParameter("pipeline, mascot server"); parser.removeInputParameter("pipeline, mascot http proxy"); - return super.createProtocolInstance(parser); + return super.createProtocolInstance(parser, container); } } diff --git a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupDefaults.xml b/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupDefaults.xml deleted file mode 100644 index 8114e8f2d3..0000000000 --- a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupDefaults.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineJob.java b/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineJob.java deleted file mode 100644 index 0a25ca8f43..0000000000 --- a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineJob.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.rollup; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.labkey.api.pipeline.PipeRoot; -import org.labkey.api.pipeline.TaskId; -import org.labkey.api.pipeline.file.AbstractFileAnalysisJob; -import org.labkey.api.view.ViewBackgroundInfo; -import org.labkey.ms2.pipeline.AbstractMS2SearchPipelineJob; -import org.labkey.ms2.pipeline.tandem.XTandemSearchTask; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Job for rolling up multiple search engine results (after the search has already been completed) into a combined - * set of analysis results. Currently only works for .xtan.xml files - XTandem's native output file format. - * @author jeckels - */ -public class FractionRollupPipelineJob extends AbstractMS2SearchPipelineJob -{ - private static final Logger LOG = getJobLogger(FractionRollupPipelineJob.class); - protected static final TaskId TASK_ID = new TaskId(FractionRollupPipelineJob.class); - - @Override - public Logger getClassLogger() - { - return LOG; - } - - @JsonCreator - protected FractionRollupPipelineJob(@JsonProperty("_dirSequenceRoot") File dirSequenceRoot) - { - super(dirSequenceRoot); - } - - public FractionRollupPipelineJob(FractionRollupProtocol protocol, - ViewBackgroundInfo info, - PipeRoot root, - String name, - List filesXtanXML, - File fileInputXML) throws IOException - { - super(protocol, FractionRollupPipelineProvider.NAME, info, root, name, null, fileInputXML, filesXtanXML); - - _fractions = true; - - header("Fraction rollup analysis " + getBaseName()); - writeInputFilesToLog(); - } - - public FractionRollupPipelineJob(FractionRollupPipelineJob job, File fileFraction) - { - super(job, fileFraction); - } - - @Override - public List getInteractInputFiles() - { - List files = new ArrayList<>(); - for (File xtanXMLFile : getInputFiles()) - { - files.add(getPepXMLConvertFile(getAnalysisDirectory(), - XTandemSearchTask.getNativeFileType(getGZPreference()).getBaseName(xtanXMLFile), - getGZPreference())); - } - return files; - } - - @Override - public TaskId getTaskPipelineId() - { - return TASK_ID; - } - - @Override - public AbstractFileAnalysisJob createSingleFileJob(File file) - { - return new FractionRollupPipelineJob(this, file); - } - - @Override - public File getSearchNativeOutputFile() - { - throw new UnsupportedOperationException(); - } -} \ No newline at end of file diff --git a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineProvider.java deleted file mode 100644 index 1be79c78ef..0000000000 --- a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupPipelineProvider.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2015-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.rollup; - -import org.labkey.api.data.Container; -import org.labkey.api.module.Module; -import org.labkey.api.pipeline.PipeRoot; -import org.labkey.api.pipeline.PipelineActionConfig; -import org.labkey.api.pipeline.PipelineDirectory; -import org.labkey.api.pipeline.TaskPipeline; -import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; -import org.labkey.api.security.permissions.InsertPermission; -import org.labkey.api.view.ViewContext; -import org.labkey.ms2.pipeline.AbstractMS2PipelineProvider; -import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; -import org.labkey.ms2.pipeline.AbstractMS2SearchTaskFactory; -import org.labkey.ms2.pipeline.MS2PipelineManager; -import org.labkey.ms2.pipeline.PipelineController; -import org.labkey.ms2.pipeline.tandem.XTandemSearchTask; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -/** - * Accepts .xtan.xml files and shows a pipeline action letting the user combine the files into a single - * set of combined search results. - * @author jeckels - */ -public class FractionRollupPipelineProvider extends AbstractMS2PipelineProvider -{ - public static final String NAME = "FractionRollup"; - private static final String ACTION_LABEL = "Fraction Rollup Analysis"; - - public FractionRollupPipelineProvider(Module owningModule) - { - super(NAME, owningModule); - } - - @Override - public boolean isStatusViewableFile(Container container, String name, String basename) - { - String nameParameters = FractionRollupProtocolFactory.get().getParametersFileName(); - return nameParameters.equals(name) || super.isStatusViewableFile(container, name, basename); - } - - @Override - public void updateFileProperties(ViewContext context, PipeRoot pr, PipelineDirectory directory, boolean includeAll) - { - XTandemSearchTask.Factory factory = AbstractMS2SearchTaskFactory.findFactory(XTandemSearchTask.Factory.class); - if (factory != null && !factory.isEnabled()) - { - return; - } - - if (!context.getContainer().hasPermission(context.getUser(), InsertPermission.class)) - { - return; - } - - String actionId = createActionId(PipelineController.FractionRollupAction.class, ACTION_LABEL); - addAction(actionId, PipelineController.FractionRollupAction.class, ACTION_LABEL, - directory, directory.listFiles(new MS2PipelineManager.XtanXmlFileFilter()), true, true, includeAll); - } - - @Override - public List getDefaultActionConfigSkipModuleEnabledCheck(Container container) - { - XTandemSearchTask.Factory factory = AbstractMS2SearchTaskFactory.findFactory(XTandemSearchTask.Factory.class); - if (factory != null && !factory.isEnabled()) - { - return super.getDefaultActionConfigSkipModuleEnabledCheck(container); - } - - String actionId = createActionId(PipelineController.FractionRollupAction.class, ACTION_LABEL); - return Collections.singletonList(new PipelineActionConfig(actionId, PipelineActionConfig.displayState.toolbar, ACTION_LABEL, true)); - } - - @Override - public AbstractFileAnalysisProtocolFactory getProtocolFactory(TaskPipeline pipeline) - { - return FractionRollupProtocolFactory.get(); - } - - @Override - public AbstractFileAnalysisProtocolFactory getProtocolFactory(File file) - { - return FractionRollupProtocolFactory.get(); - } - - @Override - public AbstractMS2SearchProtocolFactory getProtocolFactory() - { - return FractionRollupProtocolFactory.get(); - } - - @Override - public String getHelpTopic() - { - return "pipelineparams"; - } - - @Override - public boolean isSearch() - { - return false; - } - - @Override - public boolean dbExists(Container container, File sequenceRoot, String s) - { - throw new UnsupportedOperationException(); - } - - @Override - public void ensureEnabled(Container container) - { - // This is always available - } -} - diff --git a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocol.java b/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocol.java deleted file mode 100644 index 30aa39eac2..0000000000 --- a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocol.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.rollup; - -import org.jetbrains.annotations.Nullable; -import org.labkey.api.pipeline.PipeRoot; -import org.labkey.api.pipeline.PipelineValidationException; -import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; -import org.labkey.api.util.FileType; -import org.labkey.api.view.ViewBackgroundInfo; -import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; -import org.labkey.ms2.pipeline.tandem.XTandemSearchTask; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * @author jeckels - */ -public class FractionRollupProtocol extends AbstractMS2SearchProtocol -{ - public FractionRollupProtocol(String name, String description, String xml) - { - super(name, description, xml); - } - - @Override - public AbstractFileAnalysisProtocolFactory getFactory() - { - return FractionRollupProtocolFactory.get(); - } - - @Override - public FractionRollupPipelineJob createPipelineJob(ViewBackgroundInfo info, - PipeRoot root, List filesInput, - File fileParameters, @Nullable Map variableMap - ) throws IOException - { - return new FractionRollupPipelineJob(this, info, root, getName(), - filesInput, fileParameters); - } - - @Override - public List getInputTypes() - { - return Collections.singletonList(XTandemSearchTask.getNativeFileType(FileType.gzSupportLevel.SUPPORT_GZ)); - } - - @Override - public void validate(PipeRoot root) throws PipelineValidationException - { - validateProtocolName(); - } -} diff --git a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocolFactory.java b/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocolFactory.java deleted file mode 100644 index 64636cbce3..0000000000 --- a/ms2/src/org/labkey/ms2/pipeline/rollup/FractionRollupProtocolFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.ms2.pipeline.rollup; - -import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; - -/** - * @author jeckels - */ -public class FractionRollupProtocolFactory extends AbstractMS2SearchProtocolFactory -{ - private static final FractionRollupProtocolFactory instance = new FractionRollupProtocolFactory(); - - public static FractionRollupProtocolFactory get() - { - return instance; - } - - private FractionRollupProtocolFactory() - { - // Use the get() function. - } - - @Override - public String getDefaultParametersResource() - { - return "org/labkey/ms2/pipeline/rollup/FractionRollupDefaults.xml"; - } - - @Override - public String getName() - { - return "rollup"; - } - - @Override - public FractionRollupProtocol createProtocolInstance(String name, String description, String xml) - { - return new FractionRollupProtocol(name, description, xml); - } -} diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestParams.java b/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestParams.java index dfaca7dd86..569e029c70 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestParams.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestParams.java @@ -15,7 +15,7 @@ */ package org.labkey.ms2.pipeline.sequest; -import org.labkey.ms2.pipeline.client.ParameterNames; +import org.labkey.ms2.pipeline.ParameterNames; import java.util.ArrayList; import java.util.Collection; diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestSearchTaskFactory.java b/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestSearchTaskFactory.java index 64639a726c..e7e8f83b90 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestSearchTaskFactory.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/AbstractSequestSearchTaskFactory.java @@ -37,7 +37,7 @@ public abstract class AbstractSequestSearchTaskFactory _sequestOptions = new ArrayList<>(); - protected AbstractSequestSearchTaskFactory(Class namespaceClass) + protected AbstractSequestSearchTaskFactory(Class namespaceClass) { super(namespaceClass); } diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParams.java b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParams.java index 66aa07bf2e..c5c6c11d6c 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParams.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParams.java @@ -17,7 +17,7 @@ package org.labkey.ms2.pipeline.sequest; import org.labkey.ms2.pipeline.AbstractMS2SearchTask; -import org.labkey.ms2.pipeline.client.ParameterNames; +import org.labkey.ms2.pipeline.ParameterNames; /** * User: billnelson@uky.edu diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParamsBuilder.java b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParamsBuilder.java index d40e1e5ed1..59345deb3f 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParamsBuilder.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestParamsBuilder.java @@ -30,7 +30,7 @@ import org.labkey.ms2.MS2Module; import org.labkey.ms2.pipeline.AbstractMS2SearchTask; import org.labkey.ms2.pipeline.MS2PipelineManager; -import org.labkey.ms2.pipeline.client.ParameterNames; +import org.labkey.ms2.pipeline.ParameterNames; import java.io.BufferedWriter; import java.io.File; diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineJob.java b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineJob.java index 5364e3dbc7..036ce9a55e 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineJob.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineJob.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; /** @@ -35,7 +36,7 @@ */ public class SequestPipelineJob extends AbstractMS2SearchPipelineJob { - private static final TaskId TASK_ID = new TaskId(SequestPipelineJob.class); + public static final TaskId TASK_ID = new TaskId(SequestPipelineJob.class); @JsonCreator protected SequestPipelineJob(@JsonProperty("_dirSequenceRoot") File dirSequenceRoot) @@ -47,12 +48,11 @@ public SequestPipelineJob(SequestSearchProtocol protocol, ViewBackgroundInfo info, PipeRoot root, String name, - File dirSequenceRoot, - List filesMzXML, - File fileInputXML + List filesMzXML, + Path fileInputXML ) throws IOException { - super(protocol, SequestPipelineProvider.name, info, root, name, dirSequenceRoot, fileInputXML, filesMzXML); + super(protocol, SequestPipelineProvider.name, info, root, name, fileInputXML, filesMzXML); header("Sequest search for " + getBaseName()); writeInputFilesToLog(); diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineProvider.java index bbc571fd03..2b6f9c6b21 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineProvider.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestPipelineProvider.java @@ -32,14 +32,11 @@ import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; import org.labkey.ms2.pipeline.MS2PipelineManager; import org.labkey.ms2.pipeline.PipelineController; -import org.labkey.ms2.pipeline.SearchFormUtil; import java.io.File; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; /** * User: billnelson@uky.edu @@ -69,16 +66,23 @@ protected boolean isEnabled() if (!super.isEnabled()) return false; - AbstractSequestSearchTaskFactory sequestFactory = findFactory(); + AbstractSequestSearchTaskFactory sequestFactory = findFactory(); return sequestFactory != null && (sequestFactory.getLocation() != null || sequestFactory.getSequestInstallDir() != null); } @Override public void updateFilePropertiesEnabled(ViewContext context, PipeRoot pr, PipelineDirectory directory, boolean includeAll) { - String actionId = createActionId(PipelineController.SearchSequestAction.class, ACTION_LABEL); - addAction(actionId, PipelineController.SearchSequestAction.class, ACTION_LABEL, - directory, directory.listFiles(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + String actionId = getActionId(); + addAction(actionId, getTaskPipeline(SequestPipelineJob.TASK_ID).getAnalyzeURL(context.getContainer(), null, null), ACTION_LABEL, + directory, directory.listPaths(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + } + + @Override + protected String getActionId() + { + // Retain old GWT action class as the action ID to preserve file browser button configuration + return createActionId("org.labkey.ms2.pipeline.PipelineController$SearchSequestAction", ACTION_LABEL); } @Override @@ -86,7 +90,8 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C { if (isEnabled()) { - String actionId = createActionId(PipelineController.SearchSequestAction.class, ACTION_LABEL); + // Retain old GWT action class as the action ID to preserve file browser button configuration + String actionId = getActionId(); return Collections.singletonList(new PipelineActionConfig(actionId, PipelineActionConfig.displayState.toolbar, ACTION_LABEL, true)); } return super.getDefaultActionConfigSkipModuleEnabledCheck(container); @@ -94,12 +99,12 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C @Override @NotNull - public HttpView createSetupWebPart(Container container) + public HttpView createSetupWebPart(Container container) { return new SetupWebPart(); } - class SetupWebPart extends WebPartView + static class SetupWebPart extends WebPartView { public SetupWebPart() { @@ -128,43 +133,12 @@ public AbstractMS2SearchProtocolFactory getProtocolFactory() return SequestSearchProtocolFactory.get(); } - @Override - public List getSequenceDbPaths(File sequenceRoot) - { - return MS2PipelineManager.addSequenceDbPaths(sequenceRoot, "", new ArrayList()); - } - @Override public List getSequenceDbDirList(Container container, File sequenceRoot) { return MS2PipelineManager.getSequenceDirList(sequenceRoot, ""); } - @Override - public List getTaxonomyList(Container container) - { - //"Sequest does not support Mascot style taxonomy. - return null; - } - - @Override - public Map> getEnzymes(Container container) - { - return SearchFormUtil.getDefaultEnzymeMap(); - } - - @Override - public Map getResidue0Mods(Container container) - { - return SearchFormUtil.getDefaultStaticMods(); - } - - @Override - public Map getResidue1Mods(Container container) - { - return SearchFormUtil.getDefaultDynamicMods(); - } - @Override public String getHelpTopic() { @@ -177,23 +151,4 @@ public void ensureEnabled(Container container) throws PipelineValidationExceptio if (!isEnabled()) throw new PipelineValidationException("Sequest server has not been specified in ms2Config.xml file."); } - - @Override - public boolean supportsDirectories() - { - return true; - } - - @Override - public boolean remembersDirectories() - { - return false; - } - - @Override - public boolean hasRemoteDirectories() - { - return false; - } - } diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocol.java b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocol.java index bcae7a359e..79e8648fab 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocol.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocol.java @@ -17,6 +17,7 @@ package org.labkey.ms2.pipeline.sequest; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.PipeRoot; import org.labkey.api.pipeline.PipelineValidationException; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; @@ -25,6 +26,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; import java.util.Map; @@ -35,9 +37,9 @@ */ public class SequestSearchProtocol extends AbstractMS2SearchProtocol { - public SequestSearchProtocol(String name, String description, String xml) + public SequestSearchProtocol(String name, String description, String xml, Container container) { - super(name, description, xml); + super(name, description, xml, container); } @Override @@ -48,24 +50,24 @@ public AbstractFileAnalysisProtocolFactory getFactory() @Override public SequestPipelineJob createPipelineJob(ViewBackgroundInfo info, - PipeRoot root, List filesInput, - File fileParameters, @Nullable Map variableMap + PipeRoot root, List filesInput, + Path fileParameters, @Nullable Map variableMap ) throws IOException { - return new SequestPipelineJob(this, info, root, getName(), getDirSeqRoot(), + return new SequestPipelineJob(this, info, root, getName(), filesInput, fileParameters); } @Override public void validate(PipeRoot root) throws PipelineValidationException { - String[] dbNames = getDbNames(); - if(dbNames == null || dbNames.length == 0) + List dbNames = getDbNames(); + if(dbNames.isEmpty()) throw new IllegalArgumentException("A sequence database must be selected."); - File fileSequenceDB = new File(getDirSeqRoot(), dbNames[0]); + File fileSequenceDB = new File(getDirSeqRoot(), dbNames.get(0)); if (!fileSequenceDB.exists()) - throw new IllegalArgumentException("Sequence database '" + dbNames[0] + "' is not found in local FASTA root."); + throw new IllegalArgumentException("Sequence database '" + dbNames.get(0) + "' is not found in local FASTA root."); super.validate(root); } diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocolFactory.java b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocolFactory.java index cc1ded17de..f29060d4a8 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocolFactory.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchProtocolFactory.java @@ -16,7 +16,7 @@ package org.labkey.ms2.pipeline.sequest; -import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; +import org.labkey.api.data.Container; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; /** @@ -51,9 +51,9 @@ public String getDefaultParametersResource() } @Override - public AbstractMS2SearchProtocol createProtocolInstance(String name, String description, String xml) + public SequestSearchProtocol createProtocolInstance(String name, String description, String xml, Container container) { - return new SequestSearchProtocol(name, description, xml); + return new SequestSearchProtocol(name, description, xml, container); } } diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchTask.java b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchTask.java index 1bfeb56a5d..d01e3520f3 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchTask.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/SequestSearchTask.java @@ -34,7 +34,7 @@ import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; import org.labkey.ms2.pipeline.AbstractMS2SearchTask; import org.labkey.ms2.pipeline.TPPTask; -import org.labkey.ms2.pipeline.client.ParameterNames; +import org.labkey.ms2.pipeline.ParameterNames; import java.io.BufferedReader; import java.io.BufferedWriter; diff --git a/ms2/src/org/labkey/ms2/pipeline/sequest/ThermoSequestParamsBuilder.java b/ms2/src/org/labkey/ms2/pipeline/sequest/ThermoSequestParamsBuilder.java index 6730307232..9a96032e95 100644 --- a/ms2/src/org/labkey/ms2/pipeline/sequest/ThermoSequestParamsBuilder.java +++ b/ms2/src/org/labkey/ms2/pipeline/sequest/ThermoSequestParamsBuilder.java @@ -16,7 +16,7 @@ package org.labkey.ms2.pipeline.sequest; import org.junit.Test; -import org.labkey.ms2.pipeline.client.ParameterNames; +import org.labkey.ms2.pipeline.ParameterNames; import java.io.File; import java.io.IOException; @@ -215,7 +215,7 @@ protected List initDynamicTermMods(char term, String mass) String defaultCTerm = st.nextToken(); String defaultNTerm = st.nextToken(); - if (mass == null|| mass.length() == 0) + if (mass == null|| mass.isEmpty()) { return Collections.singletonList("The mass value for term_diff_search_options is empty."); } @@ -843,9 +843,9 @@ public void testInitEnzymeInfoDefault() // actual = sp.getValue(); // assertEquals("enzyme_description", expected2, actual); - Param sp = spb.getProperties().getParam("enzyme_info"); - String actual = sp.getValue(); - assertEquals("enzyme_description", expected2, actual); + Param sp = spb.getProperties().getParam("enzyme_info"); + String actual = sp.getValue(); + assertEquals("enzyme_description", expected2, actual); } @Test diff --git a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineJob.java b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineJob.java index 854037ab6a..c563b0295a 100644 --- a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineJob.java +++ b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineJob.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import org.labkey.api.pipeline.*; import org.labkey.api.pipeline.file.AbstractFileAnalysisJob; import org.labkey.api.view.ViewBackgroundInfo; @@ -26,6 +25,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; /** @@ -56,11 +56,10 @@ public XTandemPipelineJob(XTandemSearchProtocol protocol, ViewBackgroundInfo info, PipeRoot root, String name, - File dirSequenceRoot, - List filesMzXML, - File fileInputXML) throws IOException + List filesMzXML, + Path fileInputXML) throws IOException { - super(protocol, XTandemPipelineProvider.name, info, root, name, dirSequenceRoot, fileInputXML, filesMzXML); + super(protocol, XTandemPipelineProvider.name, info, root, name, fileInputXML, filesMzXML); header("X! Tandem search for " + getBaseName()); writeInputFilesToLog(); @@ -88,7 +87,7 @@ public AbstractFileAnalysisJob createSingleFileJob(File file) public boolean isProphetEnabled() { String paramScore = getParameters().get("scoring, algorithm"); - if (paramScore == null || paramScore.length() == 0) + if (paramScore == null || paramScore.isEmpty()) paramScore = "native"; return ("native".equals(paramScore) || diff --git a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineProvider.java b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineProvider.java index cbcd13d313..d0b22f7436 100644 --- a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineProvider.java +++ b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemPipelineProvider.java @@ -30,14 +30,11 @@ import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; import org.labkey.ms2.pipeline.MS2PipelineManager; import org.labkey.ms2.pipeline.PipelineController; -import org.labkey.ms2.pipeline.SearchFormUtil; import java.io.File; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; /** * Created: Nov 1, 2005 @@ -64,9 +61,16 @@ public boolean isStatusViewableFile(Container container, String name, String bas @Override public void updateFilePropertiesEnabled(ViewContext context, PipeRoot pr, PipelineDirectory directory, boolean includeAll) { - String actionId = createActionId(PipelineController.SearchXTandemAction.class, ACTION_LABEL); - addAction(actionId, PipelineController.SearchXTandemAction.class, ACTION_LABEL, - directory, directory.listFiles(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + String actionId = getActionId(); + addAction(actionId, getTaskPipeline(XTandemPipelineJob.TASK_ID).getAnalyzeURL(context.getContainer(), directory.getRelativePath(), null), ACTION_LABEL, + directory, directory.listPaths(MS2PipelineManager.getAnalyzeFilter()), true, true, includeAll); + } + + @Override + protected String getActionId() + { + // Retain old GWT action class as the action ID to preserve file browser button configuration + return createActionId("org.labkey.ms2.pipeline.PipelineController$SearchXTandemAction", ACTION_LABEL); } @Override @@ -74,7 +78,7 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C { if (isEnabled()) { - String actionId = createActionId(PipelineController.SearchXTandemAction.class, ACTION_LABEL); + String actionId = getActionId(); return Collections.singletonList(new PipelineActionConfig(actionId, PipelineActionConfig.displayState.toolbar, ACTION_LABEL, true)); } return super.getDefaultActionConfigSkipModuleEnabledCheck(container); @@ -82,12 +86,12 @@ public List getDefaultActionConfigSkipModuleEnabledCheck(C @Override @NotNull - public HttpView createSetupWebPart(Container container) + public HttpView createSetupWebPart(Container container) { return new SetupWebPart(); } - private static class SetupWebPart extends WebPartView + private static class SetupWebPart extends WebPartView { public SetupWebPart() { @@ -102,7 +106,7 @@ protected void renderView(Object model, PrintWriter out) return; StringBuilder html = new StringBuilder(); html.append(""); - ActionURL setDefaultsURL = new ActionURL(PipelineController.SetTandemDefaultsAction.class, context.getContainer()); // TODO: Should be method in PipelineController + ActionURL setDefaultsURL = new ActionURL(PipelineController.SetTandemDefaultsAction.class, context.getContainer()); html.append("
X! Tandem specific settings:
    ") .append("Set defaults") .append(" - Specify the default XML parameters file for X! Tandem.
"); @@ -110,66 +114,18 @@ protected void renderView(Object model, PrintWriter out) } } - @Override - public boolean supportsDirectories() - { - return true; - } - - @Override - public boolean remembersDirectories() - { - return true; - } - - @Override - public boolean hasRemoteDirectories() - { - return false; - } - @Override public AbstractMS2SearchProtocolFactory getProtocolFactory() { return XTandemSearchProtocolFactory.get(); } - @Override - public List getSequenceDbPaths(File sequenceRoot) - { - return MS2PipelineManager.addSequenceDbPaths(sequenceRoot, "", new ArrayList()); - } - @Override public List getSequenceDbDirList(Container container, File sequenceRoot) { return MS2PipelineManager.getSequenceDirList(sequenceRoot, ""); } - @Override - public List getTaxonomyList(Container container) - { - //"X! Tandem does not support Mascot style taxonomy. - return null; - } - - @Override - public Map> getEnzymes(Container container) - { - return SearchFormUtil.getDefaultEnzymeMap(); - } - - @Override - public Map getResidue0Mods(Container container) - { - return SearchFormUtil.getDefaultStaticMods(); - } - - @Override - public Map getResidue1Mods(Container container) - { - return SearchFormUtil.getDefaultDynamicMods(); - } @Override public String getHelpTopic() { diff --git a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocol.java b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocol.java index ae6e1ee53e..3fc8ad21a5 100644 --- a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocol.java +++ b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocol.java @@ -18,13 +18,14 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.PipeRoot; import org.labkey.api.pipeline.file.AbstractFileAnalysisProtocolFactory; import org.labkey.api.view.ViewBackgroundInfo; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; -import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.List; import java.util.Map; @@ -39,9 +40,9 @@ public class XTandemSearchProtocol extends AbstractMS2SearchProtocol filesInput, - File fileParameters, @Nullable Map variableMap + PipeRoot root, List filesInput, + Path fileParameters, @Nullable Map variableMap ) throws IOException { - return new XTandemPipelineJob(this, info, root, getName(), getDirSeqRoot(), + return new XTandemPipelineJob(this, info, root, getName(), filesInput, fileParameters); } } diff --git a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocolFactory.java b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocolFactory.java index d61fb0bbb9..cd6a895a03 100644 --- a/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocolFactory.java +++ b/ms2/src/org/labkey/ms2/pipeline/tandem/XTandemSearchProtocolFactory.java @@ -15,6 +15,7 @@ */ package org.labkey.ms2.pipeline.tandem; +import org.labkey.api.data.Container; import org.labkey.api.pipeline.ParamParser; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocol; import org.labkey.ms2.pipeline.AbstractMS2SearchProtocolFactory; @@ -65,16 +66,16 @@ public String getDefaultParametersResource() } @Override - public XTandemSearchProtocol createProtocolInstance(String name, String description, String xml) + public XTandemSearchProtocol createProtocolInstance(String name, String description, String xml, Container container) { - return new XTandemSearchProtocol(name, description, xml); + return new XTandemSearchProtocol(name, description, xml, container); } @Override - protected AbstractMS2SearchProtocol createProtocolInstance(ParamParser parser) + protected AbstractMS2SearchProtocol createProtocolInstance(ParamParser parser, Container container) { parser.removeInputParameter("protein, taxon"); - return super.createProtocolInstance(parser); + return super.createProtocolInstance(parser, container); } } diff --git a/ms2/src/org/labkey/ms2/query/MS2Schema.java b/ms2/src/org/labkey/ms2/query/MS2Schema.java index bebd41ec1c..84e860c72a 100644 --- a/ms2/src/org/labkey/ms2/query/MS2Schema.java +++ b/ms2/src/org/labkey/ms2/query/MS2Schema.java @@ -116,10 +116,8 @@ public class MS2Schema extends UserSchema public static final String MASCOT_PROTOCOL_OBJECT_PREFIX = "MS2.Mascot"; public static final String COMET_PROTOCOL_OBJECT_PREFIX = "MS2.Comet"; public static final String SEQUEST_PROTOCOL_OBJECT_PREFIX = "MS2.Sequest"; - public static final String FRACTION_ROLLUP_PROTOCOL_OBJECT_PREFIX = "MS2.FractionRollup"; public static final String XTANDEM_PROTOCOL_OBJECT_PREFIX = "MS2.XTandem"; public static final String IMPORTED_SEARCH_PROTOCOL_OBJECT_PREFIX = "MS2.ImportedSearch"; - public static final String SAMPLE_PREP_PROTOCOL_OBJECT_PREFIX = "MS2.PreSearch."; private final ProteinGroupProteins _proteinGroupProteins = new ProteinGroupProteins(); private List _runs; @@ -224,16 +222,6 @@ public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) return searchTable; } }, - FractionRollupsRuns - { - @Override - public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) - { - ExpRunTable searchTable = ms2Schema.createSearchTable(FractionRollupsRuns.toString(), cf, FRACTION_ROLLUP_PROTOCOL_OBJECT_PREFIX); - searchTable.setDescription("Contains one row per fraction rollup analysis result loaded in this folder."); - return searchTable; - } - }, MS2SearchRuns { @Override @@ -512,7 +500,7 @@ public CompareProteinProphetTableInfo createProteinProphetCompareTable(HttpServl public ExpRunTable createRunsTable(String name, ContainerFilter filter) { - return createSearchTable(name, filter, XTANDEM_PROTOCOL_OBJECT_PREFIX, MASCOT_PROTOCOL_OBJECT_PREFIX, COMET_PROTOCOL_OBJECT_PREFIX, SEQUEST_PROTOCOL_OBJECT_PREFIX , IMPORTED_SEARCH_PROTOCOL_OBJECT_PREFIX, FRACTION_ROLLUP_PROTOCOL_OBJECT_PREFIX); + return createSearchTable(name, filter, XTANDEM_PROTOCOL_OBJECT_PREFIX, MASCOT_PROTOCOL_OBJECT_PREFIX, COMET_PROTOCOL_OBJECT_PREFIX, SEQUEST_PROTOCOL_OBJECT_PREFIX , IMPORTED_SEARCH_PROTOCOL_OBJECT_PREFIX); } public SpectraCountTableInfo createSpectraCountTable(SpectraCountConfiguration config, ViewContext context, MS2Controller.SpectraCountForm form) diff --git a/ms2/test/sampledata/xarfiles/ms2pipe/.labkey/protocols/inspect/find_minmax.xml b/ms2/test/sampledata/xarfiles/ms2pipe/.labkey/protocols/inspect/find_minmax.xml deleted file mode 100644 index 1377731e3a..0000000000 --- a/ms2/test/sampledata/xarfiles/ms2pipe/.labkey/protocols/inspect/find_minmax.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - 800 - 2000 - find1 - - false - - diff --git a/ms2/test/src/org/labkey/test/ms2/AbstractMS2SearchEngineTest.java b/ms2/test/src/org/labkey/test/ms2/AbstractMS2SearchEngineTest.java index 09bbbf2d64..42b104b7b2 100644 --- a/ms2/test/src/org/labkey/test/ms2/AbstractMS2SearchEngineTest.java +++ b/ms2/test/src/org/labkey/test/ms2/AbstractMS2SearchEngineTest.java @@ -20,7 +20,9 @@ import org.labkey.test.TestTimeoutException; import org.labkey.test.WebTestHelper; import org.labkey.test.components.ui.lineage.LineageGraph; +import org.labkey.test.util.PipelineAnalysisHelper; import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.support.ui.Select; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -30,6 +32,40 @@ public abstract class AbstractMS2SearchEngineTest extends MS2TestBase { protected boolean _useOnlyOneFasta = false; + public static final String MULTI_FASTA_PROTOCOL_XML = """ + + + Bovine_mini1.fasta;Bovine_mini2.fasta;Bovine_mini3.fasta + [KR]|{P} + 0 + 0 + 9.0@C + xpress + test2 + This is a test protocol using the defaults. + 0 + 10 + 1,3 + true + """; + + public static final String SINGLE_FASTA_PROTOCOL_XML = """ + + + Bovine_mini1.fasta + [KR]|{P} + 0 + 0 + 9.0@C + xpress + test2 + This is a test protocol using the defaults. + 0 + 10 + 1,3 + true + """; + @Override abstract protected void doCleanup(boolean afterTest) throws TestTimeoutException; @@ -53,28 +89,12 @@ public void basicMS2Check() _fileBrowserHelper.selectFileBrowserItem("bov_sample/"); setupEngine(); - waitForElement(Locator.xpath("//select[@name='sequenceDB']/option[.='" + DATABASE1 + "']"), WAIT_FOR_JAVASCRIPT); - assertTextPresent("Minimum PeptideProphet prob", "Minimum ProteinProphet prob", "Quantitation engine"); - - searchMS2LibraCheck(); - - log("Set analysis parameters."); - setFormElement(Locator.name("protocolName"), "test2"); - setFormElement(Locator.name("protocolDescription"), "This is a test protocol for Verify."); - selectOptionByText(Locator.name("sequenceDB"), DATABASE1); - - if (!_useOnlyOneFasta) - { - selectOptionByText(Locator.name("sequenceDB"), DATABASE2); - selectOptionByText(Locator.name("sequenceDB"), DATABASE3); - } + PipelineAnalysisHelper helper = new PipelineAnalysisHelper(this); + helper.waitForProtocolSelect(); + helper.setProtocol("test2", _useOnlyOneFasta ? SINGLE_FASTA_PROTOCOL_XML : MULTI_FASTA_PROTOCOL_XML); + helper.setDescription("This is a test protocol for Verify."); + clickButton("Analyze"); - setFormElement(Locator.name("configureXml"), ""); - waitAndClick(Locator.xpath("//a[@class='labkey-button']/span[text() = 'OK']")); - setFormElement(Locator.name("configureXml"), INPUT_XML); - assertTextPresent("Quantitation mass tolerance", "Quantitation residue mass label"); - setFormElement(Locator.name("minPeptideProphetProb"), "0"); - clickButton("Search"); // Search is submitted as AJAX, and upon success the browser is redirected to a new page. Wait for it to load waitForElement(Locator.linkWithText("Data Pipeline"), WAIT_FOR_JAVASCRIPT); sleep(5000); // without this sleep, some machines try to redirect back to the begin.view page after the Data Pipeline link is clicked diff --git a/ms2/test/src/org/labkey/test/ms2/params/MS2TestParams.java b/ms2/test/src/org/labkey/test/ms2/params/MS2TestParams.java index addcd91291..18e93b498b 100644 --- a/ms2/test/src/org/labkey/test/ms2/params/MS2TestParams.java +++ b/ms2/test/src/org/labkey/test/ms2/params/MS2TestParams.java @@ -15,7 +15,6 @@ */ package org.labkey.test.ms2.params; -import org.labkey.test.Locator; import org.labkey.test.pipeline.AbstractPipelineTestParams; import org.labkey.test.pipeline.PipelineWebTestBase; @@ -50,17 +49,4 @@ public void clickActionButton() _test.log("X! Tandem Search"); _test._fileBrowserHelper.selectImportDataAction("X!Tandem Peptide Search"); } - - protected void setGrouping(String grouping) - { - _test.log("Set grouping to " + grouping); - _test.selectOptionByText(Locator.name("grouping"), grouping); - _test.clickAndWait(Locator.id("viewTypeSubmitButton")); - } - - @Override - protected void clickSubmitButton() - { - _test.clickAndWait(Locator.id("button_Search")); - } } diff --git a/ms2/test/src/org/labkey/test/tests/ms2/MS2Test.java b/ms2/test/src/org/labkey/test/tests/ms2/MS2Test.java index 5dfead0da6..539da0dc5e 100644 --- a/ms2/test/src/org/labkey/test/tests/ms2/MS2Test.java +++ b/ms2/test/src/org/labkey/test/tests/ms2/MS2Test.java @@ -56,13 +56,6 @@ public class MS2Test extends AbstractMS2ImportTest protected static final String RUN_GROUP1_COMMENTS = "Here are comments."; protected static final String RUN_GROUP2_NAME = "Test Run Group 2"; protected static final String RUN_GROUP3_NAME = "Test Run Group 3"; - protected static final String PROTOCOL_NAME = "Protocol Rollup 1"; - protected static final String PROTOCOL_XML = - "\n" + - "\n" + - " Bovine_mini1.fasta\n" + - " [KR]|{P}\n" + - ""; @Override @LogMethod @@ -1198,13 +1191,14 @@ private void queryValidationTest() assertTextPresent(expectedError, 13); //add correct text - String sqlGroupNumberDisplay2 = "SELECT ProteinGroups.\"Group\", \n" + - "ProteinGroups.GroupProbability, \n" + - "ProteinGroups.ErrorRate, \n" + - "ProteinGroups.UniquePeptidesCount, \n" + - "ProteinGroups.TotalNumberPeptides, \n" + - "ProteinGroups.IndistinguishableCollectionId \n" + - "FROM ProteinGroups "; + String sqlGroupNumberDisplay2 = """ + SELECT ProteinGroups."Group",\s + ProteinGroups.GroupProbability,\s + ProteinGroups.ErrorRate,\s + ProteinGroups.UniquePeptidesCount,\s + ProteinGroups.TotalNumberPeptides,\s + ProteinGroups.IndistinguishableCollectionId\s + FROM ProteinGroups\s"""; createQuery(getProjectName() + "/ms2folder", "GroupNumberTestCorrect", "ms2", sqlGroupNumberDisplay2 + "\n", "", false); _ext4Helper.clickExt4Tab("Source"); @@ -1214,38 +1208,8 @@ private void queryValidationTest() navigateToFolder(FOLDER_NAME); } - private void fractionRollupTest() - { - navigateToFolder(FOLDER_NAME); - clickButton("Process and Import Data"); - _fileBrowserHelper.selectFileBrowserItem("bov_fract/xtandem/test1/CAexample_mini1.xtan.xml"); - _fileBrowserHelper.checkFileBrowserFileCheckbox("CAexample_mini2.xtan.xml"); - if (isElementPresent(Locator.tagWithClassContaining("span", "x4-toolbar-more-icon"))) - { - click(Locator.tagWithClassContaining("span", "x4-toolbar-more-icon")); - click(Locator.tagWithText("span", "Fraction Rollup Analysis")); - } - else - { - clickButton(" Fraction Rollup Analysis"); - } - waitForElement(Locator.input("protocolName")); - setFormElement(Locator.input("protocolName"), PROTOCOL_NAME); - setFormElement(Locator.textarea("configureXml"), PROTOCOL_XML); - clickButton("Search"); - waitForRunningPipelineJobs(defaultWaitForPage); - waitForElementWithRefresh(Locator.linkContainingText(PROTOCOL_NAME), WAIT_FOR_JAVASCRIPT); - waitAndClick(Locator.linkContainingText(PROTOCOL_NAME)); - waitForElement(Locator.linkWithText("K.LLASMLAK.A")); - DataRegionTable peptidesTable = new DataRegionTable(REGION_NAME_PEPTIDES, this); - List peptides = peptidesTable.getColumnDataAsText("Peptide"); - assertEquals(Arrays.asList("K.LLASMLAK.A", "R.Q^YALHVDGVGTK.A", "R.EFAEVVSKIRR.S", "A.KKVVAVIK.L", "K.ELQAAQAR.L", "R.EYDTSKIEAAIWK.E", "K.TEGVIPSR.E", "R.LGRHPNK.A", "K.LLASMLAK.A", "R.Q^YALHVDGVGTK.A", "R.EFAEVVSKIRR.S", "A.KKVVAVIK.L", "K.ELQAAQAR.L", "R.EYDTSKIEAAIWK.E", "K.TEGVIPSR.E", "R.LGRHPNK.A"), peptides); - } - private void cleanPipeline() { - if (PIPELINE_PATH == null) - return; File rootDir = new File(PIPELINE_PATH); delete(new File(rootDir, ".labkey/protocols/rollup/Protocol Rollup 1.xml")); } diff --git a/ms2/webapp/WEB-INF/ms2/ms2Context.xml b/ms2/webapp/WEB-INF/ms2/ms2Context.xml index e5a8d819bd..eaed7e3683 100644 --- a/ms2/webapp/WEB-INF/ms2/ms2Context.xml +++ b/ms2/webapp/WEB-INF/ms2/ms2Context.xml @@ -65,10 +65,13 @@ - + + + + org.labkey.ms2.pipeline.FastaCheckTask @@ -85,10 +88,13 @@ - + + + + org.labkey.ms2.pipeline.FastaCheckTask @@ -105,10 +111,13 @@ - + + + + org.labkey.ms2.pipeline.FastaCheckTask @@ -125,10 +134,13 @@ - + + + + org.labkey.ms2.pipeline.FastaCheckTask @@ -143,21 +155,6 @@ - - - - - - - - - - - - - - -