Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 5 additions & 60 deletions ms2/src/org/labkey/ms2/MS2Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@
import org.labkey.api.protein.MassType;
import org.labkey.api.query.FieldKey;
import org.labkey.api.util.MemTracker;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ViewContext;
import org.springframework.web.servlet.ModelAndView;

import java.io.Serializable;
import java.util.ArrayList;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class MS2Run implements Serializable
{
private static Logger _log = LogManager.getLogger(MS2Run.class);
private static final Logger _log = LogHelper.getLogger(MS2Run.class, "MS2 runs");

protected final static String[] EMPTY_STRING_ARRAY = new String[0];

Expand Down Expand Up @@ -187,11 +188,11 @@ public static MS2Run getRunFromTypeString(String type, String version)

try
{
MS2Run run = runType.getRunClass().newInstance();
MS2Run run = runType.getRunClass().getDeclaredConstructor().newInstance();
run.setType(runType.name());
return run;
}
catch (IllegalAccessException | InstantiationException e)
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -238,62 +239,6 @@ public int[] getFastaIds()
return _fastaIds;
}

// CONSIDER: extend Apache ListOrderedSet (ideally) or our ArrayListMap.
public static class ColumnNameList extends ArrayList<String>
{
public ColumnNameList(Collection<String> columnNames)
{
for (String s : columnNames)
{
add(s);
}
}

public ColumnNameList(String csvColumnNames)
{
super(20);

String[] arrayColumnNames = csvColumnNames.split(",");
for (String arrayColumnName : arrayColumnNames)
add(arrayColumnName.trim());
}

@Override
public boolean add(String o)
{
return super.add(o.toLowerCase());
}

public ColumnNameList()
{
super(20);
}

@Override
public boolean contains(Object elem)
{
if (elem instanceof String)
{
return super.contains(((String)elem).toLowerCase());
}
return super.contains(elem);
}

public String toCSVString()
{
StringBuffer sb = new StringBuffer();
for (Object o : this)
{
if (sb.length() > 0)
sb.append(',');

sb.append(o);
}
return sb.toString();
}
}


public int getRun()
{
return run;
Expand Down
3 changes: 3 additions & 0 deletions ms2/src/org/labkey/ms2/MS2RunType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.labkey.ms2.pipeline.comet.CometRun;
import org.labkey.ms2.pipeline.comet.LegacyCometRun;
import org.labkey.ms2.pipeline.mascot.MascotRun;
import org.labkey.ms2.pipeline.peaks.PeaksRun;
import org.labkey.ms2.pipeline.phenyx.PhenyxRun;
import org.labkey.ms2.pipeline.sequest.SequestRun;
import org.labkey.ms2.pipeline.tandem.XCometRun;
Expand Down Expand Up @@ -114,6 +115,8 @@ public boolean isPeptideTableHidden()
return true;
}
},
PeaksDb(PeaksRun.class,
new ScoreInfo("-10lgP", "-10lgP")),
Unknown(UnknownMS2Run.class)
{
@Override
Expand Down
43 changes: 41 additions & 2 deletions ms2/src/org/labkey/ms2/PeptideImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import org.labkey.api.protein.fasta.FastaDbLoader;
import org.labkey.api.query.FieldKey;
import org.labkey.api.security.User;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.NetworkDrive;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.ms2.pipeline.MS2PipelineManager;
import org.labkey.ms2.reader.AbstractQuantAnalysisResult;
import org.labkey.ms2.reader.MS2Loader;
import org.labkey.ms2.reader.PeptideProphetHandler;
Expand Down Expand Up @@ -127,6 +130,42 @@ public void writeRunInfo(MS2Loader.PeptideFraction fraction, MS2Progress progres
dbPaths.add(dbPath);
}

// Handle PEAKS FASTA references
for (String dbName : fraction.getDatabaseParameterValues())
{
File database = null;

// First look in the FASTA directory, with and without a .fasta extension
File databaseRoot = MS2PipelineManager.getSequenceDatabaseRoot(_container, true);
if (NetworkDrive.exists(databaseRoot))
{
database = FileUtil.appendName(databaseRoot, dbName);
if (!NetworkDrive.exists(database))
{
database = FileUtil.appendName(databaseRoot, dbName + ".fasta");
}
}

// Also try relative to the file being imported, with and without a .fasta extension
if (!NetworkDrive.exists(database))
{
database = FileUtil.appendName(new File(_path), dbName);
}
if (!NetworkDrive.exists(database))
{
database = FileUtil.appendName(new File(_path), dbName + ".fasta");
}

if (NetworkDrive.exists(database))
{
dbPaths.add(database.getAbsolutePath());
}
else
{
_log.warn("Could not find FASTA " + dbName);
}
}

try
{
// Clear any stale values so we can re-insert
Expand Down Expand Up @@ -192,7 +231,7 @@ protected String getTableColumnNames()
columnNames.append(", HitRank");
columnNames.append(", Decoy");

return super.getTableColumnNames() + columnNames.toString();
return super.getTableColumnNames() + columnNames;
}


Expand Down Expand Up @@ -299,7 +338,7 @@ public void write(MS2Loader.Peptide peptide, PeptideProphetSummary peptideProphe
// If we have quantitation, use the statement that reselects the rowId; otherwise, use the simple insert statement
PeptideProphetHandler.PeptideProphetResult pp = peptide.getPeptideProphetResult();
boolean hasProphet = (_scoringAnalysis && pp != null && pp.isSummaryLoaded());
boolean hasQuant = (null != _quantSummaries && _quantSummaries.size() > 0);
boolean hasQuant = (null != _quantSummaries && !_quantSummaries.isEmpty());

if (hasProphet || hasQuant)
{
Expand Down
8 changes: 4 additions & 4 deletions ms2/src/org/labkey/ms2/filterHeader.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
<labkey:form method="post" action="<%=bean.applyViewURL%>">
<table id="ms2RunViewConfig" class="lk-fields-table">
<tr>
<td valign=bottom><%=bean.applyView%></td>
<td valign=bottom><%= button("Go").submit(true) %></td>
<td style="vertical-align: bottom"><%=bean.applyView%></td>
<td style="vertical-align: bottom"><%= button("Go").submit(true) %></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td valign=bottom><% if (!user.isGuest()) { %>
<td style="vertical-align: bottom"><% if (!user.isGuest()) { %>
<%= button("Save View").href(bean.saveViewURL) %><% } %></td>
<td valign=bottom><% if (!user.isGuest()) { %>
<td style="vertical-align: bottom"><% if (!user.isGuest()) { %>
<%= button("Manage Views").href(bean.manageViewsURL) %><% } %></td>
</tr>
</table>
Expand Down
62 changes: 62 additions & 0 deletions ms2/src/org/labkey/ms2/pipeline/peaks/PeaksRun.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2008-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.peaks;

import org.labkey.ms2.MS2Run;
import org.labkey.ms2.MS2RunType;

/**
* Support for PEAKS data, exported as pepXML
*/
public class PeaksRun extends MS2Run
{
@Override
public MS2RunType getRunType()
{
return MS2RunType.PeaksDb;
}

@Override
public String getParamsFileName()
{
return "peaks.xml";
}

@Override
public String getChargeFilterColumnName()
{
return "-10lgP";
}

@Override
public String getChargeFilterParamName()
{
return "-10lgP";
}

@Override
public String getDiscriminateExpressions()
{
return null;
}

@Override
public String[] getGZFileExtensions()
{
return new String[0];
}
}
Loading