-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow dataset connection to sample, improve error handling #7
Changes from all commits
296c981
eaf8d7e
cb3933d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package life.qbic.io.commandline; | ||
|
||
import ch.ethz.sis.openbis.generic.OpenBIS; | ||
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSet; | ||
import java.io.File; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import life.qbic.App; | ||
import life.qbic.model.DatasetWithProperties; | ||
import life.qbic.model.download.OpenbisConnector; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Mixin; | ||
import picocli.CommandLine.Option; | ||
import picocli.CommandLine.Parameters; | ||
|
||
@Command(name = "openbis-to-seek", | ||
description = "Transfers data or metadata from openBIS to SEEK.") | ||
public class TransferDataToSeekCommand implements Runnable { | ||
|
||
@Parameters(arity = "1", paramLabel = "dataset id", description = "The code of the dataset (or its metadata) to transfer. Can be found via list-data.") | ||
private String datasetCode; | ||
@Parameters(arity = "1", paramLabel = "seek node", description = "The node in SEEK to which to transfer the dataset.") | ||
private String seekNode; | ||
@Option(names = { "-d", "--data"}, usageHelp = true, description = "Transfers the data itself to SEEK along with the metadata") | ||
private boolean transferData; | ||
@Mixin | ||
AuthenticationOptions auth = new AuthenticationOptions(); | ||
|
||
@Override | ||
public void run() { | ||
OpenBIS authentication = App.loginToOpenBIS(auth.getOpenbisPassword(), auth.getOpenbisUser(), auth.getAS(), auth.getDSS()); | ||
OpenbisConnector openbis = new OpenbisConnector(authentication); | ||
|
||
List<DataSet> datasets = openbis.findDataSets(Collections.singletonList(datasetCode)); | ||
|
||
if(datasets.isEmpty()) { | ||
System.out.println(datasetCode+" not found"); | ||
return; | ||
} | ||
DatasetWithProperties result = new DatasetWithProperties(datasets.get(0)); | ||
Optional<String> patientID = openbis.findPropertyInSampleHierarchy("PATIENT_DKFZ_ID", | ||
result.getExperiment().getIdentifier()); | ||
patientID.ifPresent(s -> result.addProperty("patientID", s)); | ||
|
||
System.out.println("Found dataset, downloading."); | ||
System.out.println(); | ||
|
||
final String tmpPath = "tmp/"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused of the purpose of this command? It downloads the data into a temp folder and afterwards deletes it again? |
||
|
||
File downloadFolder = openbis.downloadDataset(tmpPath, datasetCode); | ||
|
||
|
||
|
||
cleanupTemp(new File(tmpPath)); | ||
|
||
System.out.println("Done"); | ||
} | ||
|
||
private void cleanupTemp(File tmpFolder) { | ||
File[] files = tmpFolder.listFiles(); | ||
if (files != null) { //some JVMs return null for empty dirs | ||
for (File f : files) { | ||
if (f.isDirectory()) { | ||
cleanupTemp(f); | ||
} else { | ||
f.delete(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,13 +33,17 @@ public class UploadPetabResultCommand implements Runnable { | |
|
||
@Override | ||
public void run() { | ||
OpenBIS authentication = App.loginToOpenBIS(auth.getPassword(), auth.getUser(), auth.getAS(), auth.getDSS()); | ||
OpenBIS authentication = App.loginToOpenBIS(auth.getOpenbisPassword(), auth.getOpenbisUser(), auth.getAS(), auth.getDSS()); | ||
openbis = new OpenbisConnector(authentication); | ||
|
||
if(!pathValid(dataPath)) { | ||
System.out.printf("Path %s could not be found%n", dataPath); | ||
return; | ||
} | ||
if(!new File(dataPath).isDirectory()) { | ||
System.out.printf("%s is not a directory. Please specify the PETab directory root%n", dataPath); | ||
return; | ||
} | ||
if(!experimentExists(experimentID)) { | ||
System.out.printf("Experiment %s could not be found%n", experimentID); | ||
return; | ||
|
@@ -60,7 +64,7 @@ public void run() { | |
} | ||
System.out.println("Uploading dataset..."); | ||
//TODO copy and remove source references here | ||
DataSetPermId result = openbis.registerDataset(Path.of(dataPath), experimentID, parents); | ||
DataSetPermId result = openbis.registerDatasetForExperiment(Path.of(dataPath), experimentID, parents); | ||
System.out.printf("Dataset %s was successfully created%n", result.getPermId()); | ||
Comment on lines
+67
to
68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to differentiate between registration to an experiment and to a sample here as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the use case here was specified as always using an experiment |
||
} | ||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could there be other PatientIds classifiers? If so i'd recommend to move this into a global identifier.