### Start and Connect to SIRIUS Locally with Java SDK Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/README.md This code snippet demonstrates how to start and connect to a local SIRIUS installation using the SIRIUS Java SDK. It shows how to manage the SDK lifecycle, retrieve SIRIUS information, create projects, import data, configure jobs, submit them for computation, and fetch results. The example utilizes a try-with-resources statement for automatic shutdown of the SIRIUS instance. ```java // Search and Start SIRIUS installation in background. // If a compatible SIRIUS instance is already running this will be used instead // Closing the SiriusSDK shuts down SIRIUS depending on the ShutdownMode. try (SiriusSDK sirius = SiriusSDK.startAndConnectLocally(SiriusSDK.ShutdownMode.AUTO, false)) { // print some infos about the SIRIUS instance System.out.println(sirius.infos().getInfo(null, null)); ProjectInfo project = sirius.projects().createProject("myProject", "/tmp/" + UUID.randomUUID(), null); // Import peak-list data from files. sirius.projects().importPreprocessedData(project.getProjectId(), true, true, List.of( new File("/mydata/spectra1.mgf"), new File("/mydata/spectra1.ms"), new File("/mydata/spectra1.cef") )); //get default compute configuration/parameters from SIRIUS (optional) JobSubmission sub = sirius.jobs().getDefaultJobConfig(false); sub.getZodiacParams().setEnabled(false); //enable/disable tools //submit job to be computed in background Job job = sirius.jobs().startJob(project.getProjectId(), sub, null); job = sirius.awaitJob(project.getProjectId(), job.getId()); // fetch results from the project sirius.features().getAlignedFeatures(project.getProjectId(), List.of(AlignedFeatureOptField.TOPANNOTATIONS)) .forEach(System.out::println); } catch (Exception e) { e.printStackTrace(); } ``` -------------------------------- ### Start Sirius Application (Gradle) Source: https://github.com/sirius-ms/sirius/blob/stable/sirius_rest_service/README.md This command uses Gradle to start the Sirius application. Ensure you have Gradle installed and configured in your environment. ```bash gradle bootRun ``` -------------------------------- ### Start Command using Java Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/JobsApi.md Starts a computation for a given command and input within a specified project. This method is deprecated and relies on local file paths. Dependencies include the Sirius SDK client library. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.JobsApi; import java.util.Arrays; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); JobsApi apiInstance = new JobsApi(defaultClient); String projectId = "projectId_example"; // String | project-space to perform the command for. CommandSubmission commandSubmission = new CommandSubmission(); // CommandSubmission | the command and the input to be executed List optFields = Arrays.asList(); // List | set of optional fields to be included. Use 'none' only to override defaults. try { Job result = apiInstance.startCommand(projectId, commandSubmission, optFields); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling JobsApi#startCommand"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Searchable Databases with Stats and Errors (Java) Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/SearchableDatabasesApi.md This Java example demonstrates how to retrieve a list of searchable databases using the Sirius MS SDK. It shows how to configure the API client, instantiate the SearchableDatabasesApi, and call the getDatabases method with optional parameters for including statistics and databases with errors. Error handling for API exceptions is also included. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.SearchableDatabasesApi; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); SearchableDatabasesApi apiInstance = new SearchableDatabasesApi(defaultClient); Boolean includeStats = false; // Boolean | Boolean includeWithErrors = false; // Boolean | try { List result = apiInstance.getDatabases(includeStats, includeWithErrors); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling SearchableDatabasesApi#getDatabases"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### GET /projects Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md Retrieves a list of all opened project spaces available in the system. ```APIDOC ## GET /projects ### Description Retrieves a list of all opened project spaces available in the system. ### Method GET ### Endpoint /projects ### Parameters This endpoint does not require any parameters. ### Request Example ```java // Example request (conceptual, actual client code would be used) GET /projects ``` ### Response #### Success Response (200) - **List** (List) - A list of project information objects. #### Response Example ```json [ { "id": "project1", "name": "Project Alpha", "description": "First project.", "createdAt": "2023-10-26T09:00:00Z", "updatedAt": "2023-10-26T09:00:00Z" }, { "id": "project2", "name": "Project Beta", "description": "Second project.", "createdAt": "2023-10-26T09:30:00Z", "updatedAt": "2023-10-26T09:30:00Z" } ] ``` ``` -------------------------------- ### Install SIRIUS SDK API Client using Maven Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/README.md Installs the SIRIUS SDK API client library to your local Maven repository. This command cleans the project and then installs the artifacts. It's a prerequisite for using the library in Maven projects. ```shell mvn clean install ``` -------------------------------- ### Sign Up - Java Example Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/LoginAndAccountApi.md This Java code snippet shows how to obtain a sign-up link by calling the `signUp` method. This method does not require any parameters and returns a string representing the sign-up link. Error handling for API exceptions is included. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.LoginAndAccountApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); LoginAndAccountApi apiInstance = new LoginAndAccountApi(defaultClient); try { String result = apiInstance.signUp(); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling LoginAndAccountApi#signUp"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get All Tag Definitions in Project (Java) Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/TagsApi.md This Java code snippet shows how to retrieve a list of all tag definitions within a specified project using the TagsApi. It accepts an optional tagType parameter to filter the results. The example includes API client setup, method invocation, and exception handling. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.TagsApi; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); TagsApi apiInstance = new TagsApi(defaultClient); String projectId = "projectId_example"; // String | project-space to read from. String tagType = "tagType_example"; // String | scope of the tag (optional) try { List result = apiInstance.getTags(projectId, tagType); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling TagsApi#getTags"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Import Preprocessed Data as Job (Java) Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md Imports MS/MS data from specified formats (ms, mgf, cef, msp) into a SIRIUS project space as a background job. This Java example demonstrates how to use the `ProjectsApi` client to initiate the import process, specifying project ID, input files, and optional parameters like formula handling and MS1 data inclusion. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.ProjectsApi; import java.util.List; import java.util.Arrays; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); ProjectsApi apiInstance = new ProjectsApi(defaultClient); String projectId = "projectId_example"; // String | project-space to import into. List inputFiles = Arrays.asList(); // List | Boolean ignoreFormulas = false; // Boolean | Boolean allowMs1Only = true; // Boolean | List optFields = Arrays.asList(); // List | set of optional fields to be included. Use 'none' only to override defaults. try { Job result = apiInstance.importPreprocessedDataAsJob(projectId, inputFiles, ignoreFormulas, allowMs1Only, optFields); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProjectsApi#importPreprocessedDataAsJob"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Isotope Pattern Annotation using Java Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/FeaturesApi.md Fetches isotope pattern information, including simulated and measured patterns, for a specified formula ID. This Java example shows how to initialize the API client, call the relevant method, and manage exceptions. It depends on the Sirius MS SDK. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.FeaturesApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); FeaturesApi apiInstance = new FeaturesApi(defaultClient); String projectId = "projectId_example"; // String | project-space to read from. String alignedFeatureId = "alignedFeatureId_example"; // String | feature (aligned over runs) the formula result belongs to. String formulaId = "formulaId_example"; // String | identifier of the requested formula result try { IsotopePatternAnnotation result = apiInstance.getIsotopePatternAnnotation(projectId, alignedFeatureId, formulaId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FeaturesApi#getIsotopePatternAnnotation"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Open Portal - Java Example Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/LoginAndAccountApi.md This Java code snippet demonstrates how to initialize the API client and call the `openPortal` method. It includes error handling for API exceptions. The method does not require any parameters and returns an empty response body. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.LoginAndAccountApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); LoginAndAccountApi apiInstance = new LoginAndAccountApi(defaultClient); try { apiInstance.openPortal(); } catch (ApiException e) { System.err.println("Exception when calling LoginAndAccountApi#openPortal"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### POST /signUp Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/LoginAndAccountApi.md Opens the sign-up window in the system browser and returns the sign-up link. This endpoint does not require any parameters. ```APIDOC ## POST /signUp ### Description Opens the sign-up window in the system browser and returns the sign-up link. ### Method POST ### Endpoint /signUp ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java // Import classes: import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.LoginAndAccountApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); LoginAndAccountApi apiInstance = new LoginAndAccountApi(defaultClient); try { String result = apiInstance.signUp(); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling LoginAndAccountApi#signUp"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` ### Response #### Success Response (200) - **String** - The sign-up link. #### Response Example ```json { "example": "http://example.com/signup" } ``` ``` -------------------------------- ### Get Fragmentation Tree using Java Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/FeaturesApi.md Retrieves fragmentation tree data for a given project, aligned feature, and formula ID. This example demonstrates setting up the API client, making the request, and handling potential API exceptions. It requires the Sirius MS SDK client libraries. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.FeaturesApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); FeaturesApi apiInstance = new FeaturesApi(defaultClient); String projectId = "projectId_example"; // String | project-space to read from. String alignedFeatureId = "alignedFeatureId_example"; // String | feature (aligned over runs) the formula result belongs to. String formulaId = "formulaId_example"; // String | identifier of the requested formula result try { FragmentationTree result = apiInstance.getFragTree(projectId, alignedFeatureId, formulaId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FeaturesApi#getFragTree"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Specific Database by ID using Java Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/SearchableDatabasesApi.md Retrieves a specific searchable database by its unique identifier. This Java example shows how to use the SearchableDatabasesApi client to call the getDatabase method, passing the databaseId and an optional includeStats parameter. The method returns a single SearchableDatabase object. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.SearchableDatabasesApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); SearchableDatabasesApi apiInstance = new SearchableDatabasesApi(defaultClient); String databaseId = "databaseId_example"; // String | Boolean includeStats = true; // Boolean | try { SearchableDatabase result = apiInstance.getDatabase(databaseId, includeStats); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling SearchableDatabasesApi#getDatabase"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Complete SIRIUS Java SDK Workflow Example Source: https://context7.com/sirius-ms/sirius/llms.txt This Java code demonstrates a full workflow using the SIRIUS SDK. It initializes SIRIUS, creates a project, imports data, configures and runs a job with multiple analysis modules, and then retrieves and prints the results. Dependencies include the SIRIUS SDK library. ```java import io.sirius.ms.sdk.SiriusSDK; import io.sirius.ms.sdk.model.*; import java.io.File; import java.util.List; import java.util.UUID; public class SiriusWorkflowExample { public static void main(String[] args) { // Start SIRIUS and connect (auto-shutdown when closed) try (SiriusSDK sirius = SiriusSDK.startAndConnectLocally( SiriusSDK.ShutdownMode.AUTO, false)) { // Print version info Info info = sirius.infos().getInfo(true, false); System.out.println("SIRIUS Version: " + info.getSiriusVersion()); // Create a new project String projectId = "analysis-" + UUID.randomUUID().toString().substring(0, 8); ProjectInfo project = sirius.projects().createProject( projectId, "/tmp/" + projectId, null); System.out.println("Created project: " + project.getProjectId()); // Import MS data from files sirius.projects().importPreprocessedData( project.getProjectId(), true, // ignoreFormulas true, // allowMs1Only List.of( new File("/data/spectra.mgf"), new File("/data/compounds.ms") )); // Get default job configuration and customize JobSubmission jobConfig = sirius.jobs().getDefaultJobConfig(false); // Enable SIRIUS formula identification jobConfig.getFormulaIdParams().setEnabled(true); jobConfig.getFormulaIdParams().setMassAccuracyPpm(10.0); // Enable ZODIAC for improved formula ranking jobConfig.getZodiacParams().setEnabled(true); // Enable CSI:FingerID structure search jobConfig.getFingerprintPredictionParams().setEnabled(true); jobConfig.getStructureDbSearchParams().setEnabled(true); jobConfig.getStructureDbSearchParams().setStructureSearchDBs( List.of("BIO", "PUBCHEM")); // Enable CANOPUS compound class prediction jobConfig.getCanopusParams().setEnabled(true); // Submit and wait for job completion Job job = sirius.jobs().startJob(project.getProjectId(), jobConfig, null); System.out.println("Started job: " + job.getId()); job = sirius.awaitJob(project.getProjectId(), job.getId()); System.out.println("Job completed with state: " + job.getState()); // Retrieve and display results List features = sirius.features().getAlignedFeatures( project.getProjectId(), List.of(AlignedFeatureOptField.TOPANNOTATIONS)); for (AlignedFeature feature : features) { System.out.println("\n=== Feature: " + feature.getAlignedFeatureId() + " ==="); System.out.println("Ion mass: " + feature.getIonMass()); System.out.println("Adducts: " + feature.getDetectedAdducts()); if (feature.getTopAnnotations() != null) { FeatureAnnotations ann = feature.getTopAnnotations(); if (ann.getFormulaAnnotation() != null) { System.out.println("Formula: " + ann.getFormulaAnnotation().getMolecularFormula()); } if (ann.getStructureAnnotation() != null) { System.out.println("Structure: " + ann.getStructureAnnotation().getStructureName()); System.out.println("SMILES: " + ann.getStructureAnnotation().getSmiles()); } if (ann.getCompoundClassAnnotation() != null) { System.out.println("Compound class: " + ann.getCompoundClassAnnotation().getClassificationPath()); } } } } catch (Exception e) { e.printStackTrace(); } } } ``` -------------------------------- ### Get Custom Databases using Java Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/SearchableDatabasesApi.md Retrieves a list of custom searchable databases. This Java example demonstrates how to use the SearchableDatabasesApi client to call the getCustomDatabases method. It allows optional parameters to include statistics and databases with errors. The method returns a List of SearchableDatabase objects. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.SearchableDatabasesApi; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); SearchableDatabasesApi apiInstance = new SearchableDatabasesApi(defaultClient); Boolean includeStats = false; // Boolean | Boolean includeWithErrors = false; // Boolean | try { List result = apiInstance.getCustomDatabases(includeStats, includeWithErrors); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling SearchableDatabasesApi#getCustomDatabases"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get De Novo Structure Candidates by Formula (Java) Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/FeaturesApi.md This Java code snippet demonstrates how to fetch de novo structure candidates for a given formula ID. It configures the API client, sets the base path, and calls the `getDeNovoStructureCandidatesByFormulaPaged` method from the `FeaturesApi`. The example includes error handling for API exceptions and prints the results. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.FeaturesApi; import java.util.List; import java.util.Arrays; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); FeaturesApi apiInstance = new FeaturesApi(defaultClient); String projectId = "projectId_example"; // String | project-space to read from. String alignedFeatureId = "alignedFeatureId_example"; // String | feature (aligned over runs) the formula result belongs to. String formulaId = "formulaId_example"; // String | identifier of the requested formula result Integer page = 0; // Integer | Zero-based page index (0..N) Integer size = 20; // Integer | The size of the page to be returned List sort = Arrays.asList(); // List | Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported. List optFields = Arrays.asList(); // List | set of optional fields to be included. Use 'none' only to override defaults. try { PagedModelStructureCandidateScored result = apiInstance.getDeNovoStructureCandidatesByFormulaPaged(projectId, alignedFeatureId, formulaId, page, size, sort, optFields); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FeaturesApi#getDeNovoStructureCandidatesByFormulaPaged"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Open GUI Instance with Java SDK Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/GuiApi.md This Java code snippet demonstrates how to initialize the API client, set the base path, and call the `openGui` method from the `GuiApi` class to open a GUI instance for a specified project ID. It includes basic error handling for API exceptions. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.GuiApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); GuiApi apiInstance = new GuiApi(defaultClient); String projectId = "projectId_example"; // String | of project-space the GUI instance will connect to. try { apiInstance.openGui(projectId); } catch (ApiException e) { System.err.println("Exception when calling GuiApi#openGui"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### GET /api/account/signUp Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/LoginAndAccountApi.md Opens the sign-up window in the system browser and returns the sign-up link. ```APIDOC ## GET /api/account/signUp ### Description Open SignUp window in system browser and return signUp link. ### Method GET ### Endpoint /api/account/signUp ### Parameters This endpoint does not require any parameters. ### Request Example ```java // Example request (Java SDK) ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); LoginAndAccountApi apiInstance = new LoginAndAccountApi(defaultClient); String result = apiInstance.signUp(); ``` ### Response #### Success Response (200) - **String** - The sign-up link. #### Response Example ```json { "example": "https://sirius.example.com/signup?token=abcdef12345" } ``` ``` -------------------------------- ### Get Structure Annotated Spectrum Experimental Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/FeaturesApi.md Retrieves an experimental fragmentation spectrum annotated with fragments and losses for a given formula ID and InChIKey. This Java example shows how to call the FeaturesApi with project ID, aligned feature ID, formula ID, InChIKey, spectrum index, and a search prepared flag. It includes error handling for API exceptions. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.FeaturesApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); FeaturesApi apiInstance = new FeaturesApi(defaultClient); String projectId = "projectId_example"; // String | project-space to read from. String alignedFeatureId = "alignedFeatureId_example"; // String | feature (aligned over runs) the formula result belongs to. String formulaId = "formulaId_example"; // String | identifier of the requested formula result String inchiKey = "inchiKey_example"; // String | 2d InChIKey of the structure candidate to be used to annotate the spectrum annotation Integer spectrumIndex = -1; // Integer | index of the spectrum to be annotated. Merged MS/MS will be used if spectrumIndex < 0 (default) Boolean searchPrepared = false; // Boolean | try { AnnotatedSpectrum result = apiInstance.getStructureAnnotatedSpectrumExperimental(projectId, alignedFeatureId, formulaId, inchiKey, spectrumIndex, searchPrepared); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FeaturesApi#getStructureAnnotatedSpectrumExperimental"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### List All Projects (Java) Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md Fetches a list of all available opened project spaces. This operation is straightforward and requires basic API client setup. It returns a list of ProjectInfo objects. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.ProjectsApi; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); ProjectsApi apiInstance = new ProjectsApi(defaultClient); try { List result = apiInstance.getProjects(); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProjectsApi#getProjects"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Structure Annotated Spectral Library Match Experimental Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/FeaturesApi.md Retrieves an annotated spectral library match for a given project, aligned feature, and match ID. This Java example demonstrates how to use the FeaturesApi client to make the request and handle potential API exceptions. It requires project ID, aligned feature ID, and match ID as input. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.FeaturesApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); FeaturesApi apiInstance = new FeaturesApi(defaultClient); String projectId = "projectId_example"; // String | project-space to read from. String alignedFeatureId = "alignedFeatureId_example"; // String | feature (aligned over runs) the structure candidates belong to. String matchId = "matchId_example"; // String | id of the library match to be returned. try { AnnotatedSpectrum result = apiInstance.getStructureAnnotatedSpectralLibraryMatchExperimental(projectId, alignedFeatureId, matchId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FeaturesApi#getStructureAnnotatedSpectralLibraryMatchExperimental"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### POST /api/projects/{projectId}/gui Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/GuiApi.md Open a GUI instance for the specified project-space and bring the GUI window to the foreground. This action initiates or focuses an existing GUI session. ```APIDOC ## POST /api/projects/{projectId}/gui ### Description Open GUI instance on specified project-space and bring the GUI window to foreground. ### Method POST ### Endpoint /api/projects/{projectId}/gui ### Parameters #### Path Parameters - **projectId** (String) - Required - The ID of the project-space for which to open the GUI instance. ### Request Example ```json { "projectId": "your_project_id" } ``` ### Response #### Success Response (200) - **String** - Identifier for the opened GUI instance. #### Response Example ```json { "guiId": "gui_instance_123" } ``` ``` -------------------------------- ### GET /api/projects/{projectId} Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md Get project space info by its projectId. ```APIDOC ## GET /api/projects/{projectId} ### Description Get project space info by its projectId. ### Method GET ### Endpoint /api/projects/{projectId} #### Path Parameters - **projectId** (string) - Required - The ID of the project. ### Response #### Success Response (200) - **projectInfo** (object) - Information about the project. #### Response Example ```json { "projectInfo": { "id": "example_project_id", "name": "Example Project", "location": "/path/to/project" } } ``` ``` -------------------------------- ### Import Preprocessed Data using Java Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md This example demonstrates how to import preprocessed MS/MS data (formats: ms, mgf, cef, msp) into a project using the Sirius MS Java SDK. It allows specifying input files, and optional parameters to ignore formulas and allow MS1-only data. The function returns an ImportResult object. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.ProjectsApi; import java.io.File; import java.util.Arrays; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); ProjectsApi apiInstance = new ProjectsApi(defaultClient); String projectId = "projectId_example"; // String | project-space to import into. List inputFiles = Arrays.asList(); // List | files to import into project Boolean ignoreFormulas = false; // Boolean | Boolean allowMs1Only = true; // Boolean | try { ImportResult result = apiInstance.importPreprocessedData(projectId, inputFiles, ignoreFormulas, allowMs1Only); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProjectsApi#importPreprocessedData"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Build SIRIUS OS-Specific Installer Locally Source: https://github.com/sirius-ms/sirius/blob/stable/sirius_dist/README.md Command to build an OS-specific installer for the SIRIUS distribution locally. This process requires additional developer tools to be installed on the system. ```shell gradle clean distInstaller ``` -------------------------------- ### Import MS Run Data as Job using Java Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md This Java code shows how to import MS run data as a background job using the Sirius MS SDK. It's similar to the direct import but allows for asynchronous processing. Optional fields can be specified to customize the job output. Error handling is provided. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.ProjectsApi; import java.util.List; import java.util.Arrays; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); ProjectsApi apiInstance = new ProjectsApi(defaultClient); String projectId = "projectId_example"; // String | Project-space to import into. List inputFiles = Arrays.asList(); // List | Files to import into project. LcmsSubmissionParameters parameters = new LcmsSubmissionParameters(); // LcmsSubmissionParameters | List optFields = Arrays.asList(); // List | Set of optional fields to be included. Use 'none' only to override defaults. try { Job result = apiInstance.importMsRunDataAsJob(projectId, inputFiles, parameters, optFields); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProjectsApi#importMsRunDataAsJob"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### GET /api/projects/{projectId}/aligned-features/tagged Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/FeaturesApi.md [EXPERIMENTAL] Get features (aligned over runs) by tag. ```APIDOC ## GET /api/projects/{projectId}/aligned-features/tagged ### Description [EXPERIMENTAL] Get features (aligned over runs) by tag. ### Method GET ### Endpoint /api/projects/{projectId}/aligned-features/tagged ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project. #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "No request body example provided." } ``` ### Response #### Success Response (200) - **None specified in the provided text.** #### Response Example ```json { "example": "No response example provided." } ``` ``` -------------------------------- ### Create Project using Java SDK Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md Creates and opens a new project-space accessible via a given projectId. It takes the projectId, an optional local path for the project, and optional fields as input. The function returns the ProjectInfo of the newly created or source project. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.ProjectsApi; import java.util.Arrays; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); ProjectsApi apiInstance = new ProjectsApi(defaultClient); String projectId = "projectId_example"; // String | unique name/identifier that shall be used to access the newly created project-space. Must consist only of [a-zA-Z0-9_-]. String pathToProject = "pathToProject_example"; // String | local file path where the project will be created. If NULL, project will be stored by its projectId in default project location. DEPRECATED: This parameter relies on the local filesystem and will likely be removed in later versions of this API to allow for more flexible use cases. List optFields = Arrays.asList(); // List | try { ProjectInfo result = apiInstance.createProject(projectId, pathToProject, optFields); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProjectsApi#createProject"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Select Subscription - Java Example Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/LoginAndAccountApi.md This Java code demonstrates how to select an active subscription using the `selectSubscription` method. It requires a subscription ID (sid) as input and returns `AccountInfo`. Error handling for API exceptions is included. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.LoginAndAccountApi; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); LoginAndAccountApi apiInstance = new LoginAndAccountApi(defaultClient); String sid = "sid_example"; // String | try { AccountInfo result = apiInstance.selectSubscription(sid); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling LoginAndAccountApi#selectSubscription"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### Get Included Databases with Stats (Java) Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/SearchableDatabasesApi.md This Java code snippet shows how to fetch a list of included searchable databases using the Sirius MS SDK. It details the process of setting up the API client, creating an instance of the SearchableDatabasesApi, and invoking the getIncludedDatabases method with an optional 'includeStats' parameter. The example also includes a try-catch block for handling potential API exceptions. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.SearchableDatabasesApi; import java.util.List; public class Example { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); SearchableDatabasesApi apiInstance = new SearchableDatabasesApi(defaultClient); Boolean includeStats = false; // Boolean | try { List result = apiInstance.getIncludedDatabases(includeStats); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling SearchableDatabasesApi#getIncludedDatabases"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` -------------------------------- ### GET /api/projects/{projectId}/aligned-features/page Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/FeaturesApi.md Get all available features (aligned over runs) in the given project-space. ```APIDOC ## GET /api/projects/{projectId}/aligned-features/page ### Description Get all available features (aligned over runs) in the given project-space. ### Method GET ### Endpoint /api/projects/{projectId}/aligned-features/page ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project. #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "No request body example provided." } ``` ### Response #### Success Response (200) - **None specified in the provided text.** #### Response Example ```json { "example": "No response example provided." } ``` ``` -------------------------------- ### Open Project Source: https://github.com/sirius-ms/sirius/blob/stable/sirius-sdk/sirius-sdk.openapi/docs/ProjectsApi.md Opens an existing project-space, making it accessible via a specified projectId. It takes the projectId, an optional local path to the project, and optional fields for more details. Returns ProjectInfo upon successful opening. ```java import io.sirius.ms.sdk.client.ApiClient; import io.sirius.ms.sdk.client.ApiException; import io.sirius.ms.sdk.client.Configuration; import io.sirius.ms.sdk.client.models.*; import io.sirius.ms.sdk.api.ProjectsApi; import java.util.List; import java.util.Arrays; public class OpenProjectExample { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8888"); // Set your API base path ProjectsApi apiInstance = new ProjectsApi(defaultClient); String projectId = "projectId_example"; // unique name/identifier that shall be used to access the opened project-space. String pathToProject = "pathToProject_example"; // local file path to open the project from. If NULL, project will be loaded by it projectId from default project location. List optFields = Arrays.asList(); // try { ProjectInfo result = apiInstance.openProject(projectId, pathToProject, optFields); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling ProjectsApi#openProject"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ```