forked from genome-nexus/g2s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated swagger API and update several annotation. Now this version i…
…s ready to use
- Loading branch information
1 parent
dab1bec
commit 3f68bde
Showing
22 changed files
with
258 additions
and
215 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
45 changes: 42 additions & 3 deletions
45
pdb-alignment-api/src/main/java/org/cbioportal/pdb_annotation/web/Application.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 |
---|---|---|
@@ -1,13 +1,52 @@ | ||
package org.cbioportal.pdb_annotation.web; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
/** | ||
* Main SpringBoot Application | ||
* | ||
* @author Juexin Wang | ||
* | ||
*/ | ||
@SpringBootApplication | ||
@EnableAutoConfiguration | ||
@EnableSwagger2 | ||
public class Application { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
} | ||
|
||
@Bean | ||
public Docket annotationApi() | ||
{ | ||
// default swagger definition file location: <root>/v2/api-docs?group=pdb_annotation | ||
// default swagger UI location: <root>/swagger-ui.html | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.groupName("pdb_annotation") | ||
.apiInfo(annotationApiInfo()) | ||
.select() | ||
.paths(PathSelectors.regex("/pdb_annotation.*")) | ||
.build(); | ||
} | ||
|
||
private ApiInfo annotationApiInfo() | ||
{ | ||
return new ApiInfoBuilder() | ||
.title("PDB Annotation API") | ||
.description("PDB Annotation API") | ||
//.termsOfServiceUrl("http://terms-of-service-url") | ||
.contact("CMO, MSKCC") | ||
.license("GNU AFFERO GENERAL PUBLIC LICENSE Version 3") | ||
.licenseUrl("https://github.com/cBioPortal/pdb-annotation/blob/master/LICENSE") | ||
.version("2.0") | ||
.build(); | ||
} | ||
} |
131 changes: 74 additions & 57 deletions
131
...-api/src/main/java/org/cbioportal/pdb_annotation/web/controllers/AlignmentController.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 |
---|---|---|
@@ -1,73 +1,90 @@ | ||
package org.cbioportal.pdb_annotation.web.controllers; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import org.cbioportal.pdb_annotation.web.domain.AlignmentRepository; | ||
import org.cbioportal.pdb_annotation.web.domain.EnsemblRepository; | ||
import org.cbioportal.pdb_annotation.web.domain.PdbRepository; | ||
import org.cbioportal.pdb_annotation.web.models.Alignment; | ||
import org.cbioportal.pdb_annotation.web.persistancy.AlignmentRepository; | ||
import org.cbioportal.pdb_annotation.web.persistancy.EnsemblRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiParam; | ||
import io.swagger.annotations.ApiResponse; | ||
import io.swagger.annotations.ApiResponses; | ||
|
||
@Controller | ||
/** | ||
* | ||
* Controller of the main API: AlignmentController | ||
* | ||
* @author Juexin Wang | ||
* | ||
*/ | ||
@RestController // shorthand for @Controller, @ResponseBody | ||
@CrossOrigin(origins = "*") // allow all cross-domain requests | ||
@RequestMapping(value = "/pdb_annotation/") | ||
public class AlignmentController { | ||
|
||
@RequestMapping("/StructureMappingQuery") | ||
@ResponseBody | ||
public List<Alignment> findByEnsemblidinAlignment(String ensemblid) { | ||
|
||
List<Alignment> list = new ArrayList<Alignment>(); | ||
try { | ||
Iterator<Alignment> it = alignmentDao.findByEnsemblId(ensemblid).iterator(); | ||
while(it.hasNext()){ | ||
Alignment alignment = (Alignment)it.next(); | ||
list.add(alignment); | ||
} | ||
} | ||
catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
return list; | ||
|
||
} | ||
|
||
|
||
@RequestMapping("/ProteinIdentifierRecognitionQuery") | ||
@ResponseBody | ||
public boolean isExistedEnsemblidinAlignment(String ensemblid) { | ||
try { | ||
Iterator<Alignment> it = alignmentDao.findByEnsemblId(ensemblid).iterator(); | ||
if(it.hasNext()){ | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
return false; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
// ------------------------ | ||
// PRIVATE FIELDS | ||
// ------------------------ | ||
|
||
@Autowired | ||
private AlignmentRepository alignmentDao; | ||
|
||
//@Autowired | ||
//private EnsemblDAO ensemblDao; | ||
|
||
|
||
private AlignmentRepository alignmentRepository; | ||
private EnsemblRepository ensemblRepository; | ||
private PdbRepository pdbRepository; | ||
|
||
@Autowired | ||
public AlignmentController(AlignmentRepository alignmentRepository, EnsemblRepository ensemblRepository, | ||
PdbRepository pdbRepository) { | ||
this.alignmentRepository = alignmentRepository; | ||
this.ensemblRepository = ensemblRepository; | ||
this.pdbRepository = pdbRepository; | ||
} | ||
|
||
@ApiOperation(value = "get pdb alignments by ensemblId", nickname = "getPdbAlignmentByEnsemblId") | ||
@ApiResponses(value = { | ||
@ApiResponse(code = 200, message = "Success", response = Alignment.class, responseContainer = "List"), | ||
@ApiResponse(code = 400, message = "Bad Request") }) | ||
@RequestMapping(value = "/StructureMappingQuery", method = RequestMethod.GET, produces = "application/json") | ||
@ResponseBody | ||
@ResponseStatus(HttpStatus.OK) | ||
public List<Alignment> getPdbAlignmentByEnsemblId( | ||
@RequestParam @ApiParam(value = "Input ensembl id. For example ENSP00000483207.2", required = true, allowMultiple = true) String ensemblId) { | ||
List<Alignment> list = new ArrayList(); | ||
try { | ||
List<Alignment> it = alignmentRepository.findByEnsemblId(ensemblId); | ||
list.addAll(it); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
return list; | ||
} | ||
|
||
@ApiOperation(value = "get whether ensemblId exists by ensemblId", nickname = "getExistedEnsemblidinAlignment") | ||
@ApiResponses(value = { | ||
@ApiResponse(code = 200, message = "Success", response = Alignment.class, responseContainer = "boolean"), | ||
@ApiResponse(code = 400, message = "Bad Request") }) | ||
@RequestMapping(value = "/ProteinIdentifierRecognitionQuery", method = RequestMethod.GET, produces = "application/json") | ||
@ResponseBody | ||
@ResponseStatus(HttpStatus.OK) | ||
public boolean getExistedEnsemblidinAlignment( | ||
@RequestParam @ApiParam(value = "Input ensembl id. For example ENSP00000483207.2", required = true, allowMultiple = true) String ensemblId) { | ||
try { | ||
List<Alignment> it = alignmentRepository.findByEnsemblId(ensemblId); | ||
if (it.size() != 0) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
return false; | ||
} | ||
|
||
} |
14 changes: 0 additions & 14 deletions
14
...nment-api/src/main/java/org/cbioportal/pdb_annotation/web/controllers/MainController.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...nment-api/src/main/java/org/cbioportal/pdb_annotation/web/domain/AlignmentRepository.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,20 @@ | ||
package org.cbioportal.pdb_annotation.web.domain; | ||
|
||
import java.util.List; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.cbioportal.pdb_annotation.web.models.Alignment; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
/** | ||
* | ||
* @author Juexin Wang | ||
* | ||
*/ | ||
@Transactional | ||
public interface AlignmentRepository extends JpaRepository<Alignment, Long>{ | ||
|
||
public List<Alignment> findByEnsemblId(String ensemblId); | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...ignment-api/src/main/java/org/cbioportal/pdb_annotation/web/domain/EnsemblRepository.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,20 @@ | ||
package org.cbioportal.pdb_annotation.web.domain; | ||
|
||
import java.util.List; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.cbioportal.pdb_annotation.web.models.Alignment; | ||
import org.cbioportal.pdb_annotation.web.models.Ensembl; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
/** | ||
* | ||
* @author Juexin Wang | ||
* | ||
*/ | ||
@Transactional | ||
public interface EnsemblRepository extends JpaRepository<Alignment, Long>{ | ||
|
||
public List<Ensembl> findByEnsemblId(String ensemblId); | ||
} |
16 changes: 16 additions & 0 deletions
16
pdb-alignment-api/src/main/java/org/cbioportal/pdb_annotation/web/domain/PdbRepository.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,16 @@ | ||
package org.cbioportal.pdb_annotation.web.domain; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.cbioportal.pdb_annotation.web.models.Alignment; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
/** | ||
* | ||
* @author Juexin Wang | ||
* | ||
*/ | ||
@Transactional | ||
public interface PdbRepository extends JpaRepository<Alignment, Long>{ | ||
|
||
} |
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.