-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
M2597 Export to Galaxy in data explorer
- Loading branch information
1 parent
8f63959
commit 57d229a
Showing
8 changed files
with
276 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...-dataexplorer/src/main/java/org/molgenis/dataexplorer/galaxy/GalaxyDataExportRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.molgenis.dataexplorer.galaxy; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import org.hibernate.validator.constraints.Length; | ||
import org.hibernate.validator.constraints.URL; | ||
import org.molgenis.dataexplorer.controller.DataRequest; | ||
|
||
public class GalaxyDataExportRequest | ||
{ | ||
@NotNull | ||
@URL | ||
private String galaxyUrl; | ||
|
||
@NotNull | ||
@Length(min = 32, max = 32) | ||
private String galaxyApiKey; | ||
|
||
@NotNull | ||
private DataRequest dataRequest; | ||
|
||
public String getGalaxyUrl() | ||
{ | ||
return galaxyUrl; | ||
} | ||
|
||
public void setGalaxyUrl(String galaxyUrl) | ||
{ | ||
this.galaxyUrl = galaxyUrl; | ||
} | ||
|
||
public String getGalaxyApiKey() | ||
{ | ||
return galaxyApiKey; | ||
} | ||
|
||
public void setGalaxyApiKey(String galaxyApiKey) | ||
{ | ||
this.galaxyApiKey = galaxyApiKey; | ||
} | ||
|
||
public DataRequest getDataRequest() | ||
{ | ||
return dataRequest; | ||
} | ||
|
||
public void setDataRequest(DataRequest dataRequest) | ||
{ | ||
this.dataRequest = dataRequest; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...s-omx-dataexplorer/src/main/java/org/molgenis/dataexplorer/galaxy/GalaxyDataExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.molgenis.dataexplorer.galaxy; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import com.github.jmchilton.blend4j.galaxy.GalaxyInstance; | ||
import com.github.jmchilton.blend4j.galaxy.GalaxyInstanceFactory; | ||
import com.github.jmchilton.blend4j.galaxy.HistoriesClient; | ||
import com.github.jmchilton.blend4j.galaxy.ToolsClient; | ||
import com.github.jmchilton.blend4j.galaxy.ToolsClient.FileUploadRequest; | ||
import com.github.jmchilton.blend4j.galaxy.ToolsClient.UploadFile; | ||
import com.github.jmchilton.blend4j.galaxy.beans.History; | ||
import com.github.jmchilton.blend4j.galaxy.beans.OutputDataset; | ||
import com.github.jmchilton.blend4j.galaxy.beans.ToolExecution; | ||
|
||
public class GalaxyDataExporter | ||
{ | ||
private static final String MOLGENIS_HISTORY_NAME = "MOLGENIS history"; | ||
|
||
private final GalaxyInstance galaxyInstance; | ||
|
||
public GalaxyDataExporter(String galaxyUrl, String galaxyApiKey) | ||
{ | ||
if (galaxyUrl == null) throw new IllegalArgumentException("galaxyUrl is null"); | ||
if (galaxyApiKey == null) throw new IllegalArgumentException("galaxyApiKey is null"); | ||
this.galaxyInstance = GalaxyInstanceFactory.get(galaxyUrl, galaxyApiKey); | ||
} | ||
|
||
public void export(String dataSetName, File tsvFile) | ||
{ | ||
export(dataSetName, tsvFile, MOLGENIS_HISTORY_NAME); | ||
} | ||
|
||
public void export(String dataSetName, File tsvFile, String historyName) | ||
{ | ||
// get/create history | ||
HistoriesClient historiesClient = galaxyInstance.getHistoriesClient(); | ||
History molgenisHistory = null; | ||
for (History history : historiesClient.getHistories()) | ||
{ | ||
if (history.getName().equals(historyName)) | ||
{ | ||
molgenisHistory = history; | ||
break; | ||
} | ||
} | ||
if (molgenisHistory == null) | ||
{ | ||
molgenisHistory = new History(historyName); | ||
molgenisHistory = historiesClient.create(molgenisHistory); | ||
} | ||
|
||
// upload data set file | ||
ToolsClient toolsClient = galaxyInstance.getToolsClient(); | ||
UploadFile uploadFile = new UploadFile(tsvFile, dataSetName); | ||
FileUploadRequest fileUploadRequest = new FileUploadRequest(molgenisHistory.getId(), uploadFile); | ||
fileUploadRequest.setFileType("tabular"); | ||
ToolExecution toolsExecution = toolsClient.upload(fileUploadRequest); | ||
List<OutputDataset> outputDatasets = toolsExecution.getOutputs(); | ||
if (outputDatasets == null || outputDatasets.size() != 1) | ||
{ | ||
throw new RuntimeException("Expected one output data set instead of " + outputDatasets.size()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,6 @@ | |
display: inline; | ||
} | ||
|
||
#download-modal-button { | ||
float: right; | ||
} | ||
|
||
#genomebrowser { | ||
visibility: hidden | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.