Skip to content

Commit

Permalink
Issue #731 Metabolic pathways
Browse files Browse the repository at this point in the history
  • Loading branch information
okolesn committed Jan 21, 2022
1 parent 8e61fae commit 89b939c
Show file tree
Hide file tree
Showing 32 changed files with 1,332 additions and 6 deletions.
49 changes: 49 additions & 0 deletions docs/md/cli/command-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,55 @@ Deletes a specified lineage tree from NGB server.
$ ngb del_lineage 2
```
## Metabolic pathway commands
### Register pathway
```
ngb reg_pathway|rp [<PATH>] [options]
//Options:
//-n (--name) Pathway name
//-pt (--pretty) Pathway pretty name
```
*Description*
Registers a Pathway. One argument has to be specified:
* Pathway file path
*Example*
```bash
# Create new pathway with path "pathway.sbml"
$ ngb reg_pathway "pathway.sbml"
```
### List metabolic pathways
```
ngb list_pathway|lp
```
*Description*
List all pathways registered on NGB server.
*Example*
```bash
# List all pathways registered on NGB server
$ ngb list_pathway
```
### Delete metabolic pathway
```
ngb del_pathway|dp [<ID>]
```
*Description*
Deletes a specified pathway from NGB server.
*Example*
```bash
# Delete pathway with id 2
$ ngb del_pathway 2
```
## Utility commands
### Sort feature file
```
Expand Down
2 changes: 2 additions & 0 deletions server/catgenome/profiles/dev/catgenome.properties
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,5 @@ export.page.size=${EXPORT_PAGE_SIZE:100}
#HOMOLOGENE
homologene.index.directory=${HOMOLOGENE_INDEX_DIR:@rootDirPath@/contents/homologene}

#METABOLIC PATHWAY
pathway.index.directory=${PATHWAY_INDEX_DIRECTORY:@rootDirPath@/contents/pathway}
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ public final class MessagesConstants {
public static final String ERROR_LINEAGE_NOT_UNIQUE_NODE_NAME = "error.lineage.not.unique.node.name";
public static final String ERROR_LINEAGE_INCORRECT_EDGE = "error.lineage.incorrect.edge";

//Pathway
public static final String ERROR_PATHWAY_NOT_FOUND = "error.pathway.not.found";

//Attributes
public static final String ERROR_ATTRIBUTE_INVALID_VALUE = "error.attribute.invalid.value";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* MIT License
*
* Copyright (c) 2022 EPAM Systems
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.epam.catgenome.controller.pathway;

import com.epam.catgenome.controller.AbstractRESTController;
import com.epam.catgenome.controller.Result;
import com.epam.catgenome.controller.vo.registration.PathwayRegistrationRequest;
import com.epam.catgenome.entity.pathway.Pathway;
import com.epam.catgenome.manager.pathway.PathwaySecurityService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.apache.lucene.queryparser.classic.ParseException;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@Api(value = "pathway", description = "Metabolic Pathways Management")
@RequiredArgsConstructor
public class PathwayController extends AbstractRESTController {

private final PathwaySecurityService pathwaySecurityService;

@GetMapping(value = "/pathway/{pathwayId}")
@ApiOperation(
value = "Returns a pathway by id",
notes = "Returns a pathway by id",
produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
})
public Result<Pathway> loadPathway(@PathVariable final Long pathwayId,
@RequestParam(required = false) final Long projectId) {
return Result.success(pathwaySecurityService.loadPathway(pathwayId, projectId));
}

@GetMapping(value = "/pathways")
@ApiOperation(
value = "Returns all pathways",
notes = "Returns all pathways",
produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
})
public Result<List<Pathway>> loadPathways() {
return Result.success(pathwaySecurityService.loadPathways());
}

@PostMapping(value = "/pathway")
@ApiOperation(
value = "Registers new pathway",
notes = "Registers new pathway",
produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
})
public Result<Pathway> createPathway(@RequestBody final PathwayRegistrationRequest request)
throws IOException, ParseException {
return Result.success(pathwaySecurityService.createPathway(request));
}

@DeleteMapping(value = "/pathway/{pathwayId}")
@ApiOperation(
value = "Deletes a pathway, specified by id",
notes = "Deletes a pathway, specified by id",
produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
})
public Result<Boolean> deletePathway(@PathVariable final long pathwayId) throws IOException {
pathwaySecurityService.deletePathway(pathwayId);
return Result.success(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* MIT License
*
* Copyright (c) 2022 EPAM Systems
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.epam.catgenome.controller.vo.registration;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class PathwayRegistrationRequest extends DefaultFileRegistrationRequest {
private String name;
private String prettyName;
private String path;
private String pathwayDesc;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2016-2021 EPAM Systems
* Copyright (c) 2016-2022 EPAM Systems
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -47,6 +47,7 @@
import com.epam.catgenome.entity.heatmap.HeatmapDataType;
import com.epam.catgenome.entity.lineage.LineageTree;
import com.epam.catgenome.entity.maf.MafFile;
import com.epam.catgenome.entity.pathway.Pathway;
import com.epam.catgenome.entity.reference.Reference;
import com.epam.catgenome.entity.seg.SegFile;
import com.epam.catgenome.entity.vcf.VcfFile;
Expand Down Expand Up @@ -287,6 +288,9 @@ public enum BiologicalDataItemParameters {
NODES_PATH,
EDGES_PATH,

PATHWAY_ID,
PATHWAY_DESC,

INDEX_ID,
INDEX_NAME,
INDEX_TYPE,
Expand Down Expand Up @@ -383,6 +387,9 @@ private static BiologicalDataItem mapSpecialFields(ResultSet rs, BiologicalDataI
case LINEAGE_TREE:
dataItem = mapLineageTree(rs);
break;
case PATHWAY:
dataItem = mapPathway(rs);
break;
default:
dataItem = mapBioDataItem(rs);
}
Expand Down Expand Up @@ -413,6 +420,15 @@ private static BiologicalDataItem mapLineageTree(final ResultSet rs) throws SQLE
return lineageTree;
}

private static BiologicalDataItem mapPathway(final ResultSet rs) throws SQLException {
final Pathway pathway = Pathway.builder().build();
pathway.setId(rs.getLong(PATHWAY_ID.name()));
pathway.setPathwayId(rs.getLong(PATHWAY_ID.name()));
pathway.setPathwayDesc(rs.getString(PATHWAY_DESC.name()));
pathway.setBioDataItemId(rs.getLong(BIO_DATA_ITEM_ID.name()));
return pathway;
}

private static BiologicalDataItem mapBioDataItem(ResultSet rs) throws SQLException {
BiologicalDataItem dataItem = new BiologicalDataItem();
dataItem.setId(rs.getLong(BIO_DATA_ITEM_ID.name()));
Expand Down
Loading

0 comments on commit 89b939c

Please sign in to comment.