diff --git a/src/main/jhipster/package.json b/src/main/jhipster/package.json index 16558e1e10..2aaf2cb5d8 100644 --- a/src/main/jhipster/package.json +++ b/src/main/jhipster/package.json @@ -27,6 +27,7 @@ "core-js": "2.5.7", "d3": "^5.16.0", "d3-graphviz": "^2.6.1", + "flapjack-bytes": "git+https://github.com/cropgeeks/flapjack-bytes.git", "font-awesome": "4.7.0", "jquery": "3.2.1", "leaflet": "1.7.1", diff --git a/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.html b/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.html index e23fce5945..63cf949d40 100644 --- a/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.html +++ b/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.html @@ -98,54 +98,12 @@
-
- -
- - - - - - - - - - - - - -
MarkerGenotype Call
{{item?.variantName}}{{item?.genotype?.values[0]}}
-
-
-
-
-
-
-
- -
-
-
-
-
-
+
+ +
+
- - - - - - - - - - - - -
-
diff --git a/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.ts b/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.ts index 2ed237087a..5b0678b4ae 100644 --- a/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.ts +++ b/src/main/jhipster/src/main/webapp/app/germplasm-details/genotyping/genotyping-pane.component.ts @@ -17,6 +17,8 @@ import { Sample } from '../../entities/sample'; import { SearchGermplasmRequest } from '../../shared/brapi/model/germplasm/search-germplasm-request'; import { JhiAlertService } from 'ng-jhipster'; import { SearchSamplesRequest } from '../../shared/brapi/model/samples/search-samples-request'; +import { ExportFlapjackRequest } from '../../shared/brapi/model/export/export-flapjack-request'; +const flapjack = require('flapjack-bytes/src/flapjack-bytes'); @Component({ selector: 'jhi-genotyping-pane', @@ -29,7 +31,7 @@ export class GenotypingPaneComponent implements OnInit { totalCount = 10; page = 1; pageSize = 10; - isGenotypingCallsLoading = false; + isExportingFlapjack = false; isStudyLoading = false; isVariantSetLoading = false; isSamplesLoading = false; @@ -66,7 +68,8 @@ export class GenotypingPaneComponent implements OnInit { ngOnInit(): void { this.cropGenotypingParameterService.getByCropName(this.context.cropName).pipe(flatMap((result) => { this.cropGenotypingParameter = result; - this.genotypingBrapiService.baseUrl = this.cropGenotypingParameter.endpoint; + this.genotypingBrapiService.brapiEndpoint = this.cropGenotypingParameter.endpoint; + this.genotypingBrapiService.baseUrl = this.cropGenotypingParameter.baseUrl; return this.cropGenotypingParameterService.getToken(this.context.cropName); })).subscribe((accessToken) => { this.genotypingBrapiService.accessToken = accessToken; @@ -80,7 +83,7 @@ export class GenotypingPaneComponent implements OnInit { isGenotypingParameterConfigured() { return this.cropGenotypingParameter && this.cropGenotypingParameter.cropName && this.cropGenotypingParameter.endpoint && this.cropGenotypingParameter.tokenEndpoint - && this.cropGenotypingParameter.userName && this.cropGenotypingParameter.password && this.cropGenotypingParameter.programId; + && this.cropGenotypingParameter.userName && this.cropGenotypingParameter.password && this.cropGenotypingParameter.programId && this.cropGenotypingParameter.baseUrl; } linkBySelectOnChange() { @@ -169,32 +172,35 @@ export class GenotypingPaneComponent implements OnInit { } selectVariantsetOnChange() { - this.genotypingBrapiService.searchCallsets({ - variantSetDbIds: [this.selectedVariantSet.variantSetDbId], - germplasmDbIds: [this.genotypingGermplasm.germplasmDbId] - }).subscribe((brapiResponse) => { - if (brapiResponse && brapiResponse.result.data.length) { - this.genotypingCallSet = brapiResponse.result.data[0]; - this.loadGenotypingCalls(); - } else { - this.alertService.error('genotyping.no.genotyping.callsets.found'); - } - }); + if (this.selectedVariantSet) { + this.isExportingFlapjack = true; + const exportFlapjackRequest = new ExportFlapjackRequest([], [], 'FLAPJACK', [this.genotypingGermplasm.germplasmName], true, + 100, this.selectedVariantSet.referenceSetDbId); + this.genotypingBrapiService.exportFlapjack(exportFlapjackRequest).subscribe((response) => { + this.isExportingFlapjack = false; + let file = response.replace('.fjzip', ''); + file = this.extractHostName(this.cropGenotypingParameter.baseUrl) + file; + + const flapjackDiv = '#flapjack-div'; + const renderer = flapjack.default(); + renderer.renderGenotypesUrl({ + domParent: flapjackDiv, + width: document.querySelector(flapjackDiv).getBoundingClientRect().width, + height: 250, + mapFileURL: file + '.map', + genotypeFileURL: file + '.genotype', + phenotypeFileURL: file + '.phenotype', + overviewWidth: document.querySelector(flapjackDiv).getBoundingClientRect().width, + overviewHeight: 25, + dataSetId: this.cropGenotypingParameter.programId, + }); + }); + } } - loadGenotypingCalls() { - if (this.genotypingCallSet) { - this.isGenotypingCallsLoading = true; - this.genotypingBrapiService.searchCalls({ - callSetDbIds: [this.genotypingCallSet.callSetDbId], - pageSize: this.pageSize, - pageToken: (this.page - 1).toString() - }).subscribe(((brapiResponse) => { - this.genotypingCalls = brapiResponse.result.data; - this.totalCount = brapiResponse.metadata.pagination.totalCount; - this.isGenotypingCallsLoading = false; - })); - } + extractHostName(baseUrl) { + const { hostname, protocol } = new URL(baseUrl); + return protocol + '//' + hostname; } resetForm() { diff --git a/src/main/jhipster/src/main/webapp/app/shared/brapi/model/export/export-flapjack-request.ts b/src/main/jhipster/src/main/webapp/app/shared/brapi/model/export/export-flapjack-request.ts new file mode 100644 index 0000000000..d45948f173 --- /dev/null +++ b/src/main/jhipster/src/main/webapp/app/shared/brapi/model/export/export-flapjack-request.ts @@ -0,0 +1,11 @@ +export class ExportFlapjackRequest { + constructor( + public callSetIds: string[], + public callSetIds2: string[], + public exportFormat: string, + public exportedIndividuals: string[], + public keepExportOnServer: boolean, // Must be true, so that we can load the files from the server in flapjack-bytes + public pageSize: number, + public variantSetId: string) { + } +}; diff --git a/src/main/jhipster/src/main/webapp/app/shared/brapi/service/genotyping-brapi.service.ts b/src/main/jhipster/src/main/webapp/app/shared/brapi/service/genotyping-brapi.service.ts index c77260c732..4a978337c7 100644 --- a/src/main/jhipster/src/main/webapp/app/shared/brapi/service/genotyping-brapi.service.ts +++ b/src/main/jhipster/src/main/webapp/app/shared/brapi/service/genotyping-brapi.service.ts @@ -14,38 +14,44 @@ import { CallSet } from '../model/callsets/callset'; import { Call } from '../model/calls/call'; import { SearchSamplesRequest } from '../model/samples/search-samples-request'; import { Sample } from '../model/samples/sample'; +import { ExportFlapjackRequest } from '../model/export/export-flapjack-request'; @Injectable() export class GenotypingBrapiService { - baseUrl: string; + brapiEndpoint: string; accessToken: string; + baseUrl: string; constructor(private http: HttpClient) { } searchStudies(searchStudiesRequest: SearchStudiesRequest): Observable> { - return this.http.post>(`${this.baseUrl}/search/studies`, searchStudiesRequest, { headers: this.createHeader() }); + return this.http.post>(`${this.brapiEndpoint}/search/studies`, searchStudiesRequest, { headers: this.createHeader() }); } searchGermplasm(searchGermplasmRequest: SearchGermplasmRequest): Observable> { - return this.http.post>(`${this.baseUrl}/search/germplasm`, searchGermplasmRequest, { headers: this.createHeader() }); + return this.http.post>(`${this.brapiEndpoint}/search/germplasm`, searchGermplasmRequest, { headers: this.createHeader() }); } searchVariantsets(searchVariantsetRequest: SearchVariantsetRequest): Observable> { - return this.http.post>(`${this.baseUrl}/search/variantsets`, searchVariantsetRequest, { headers: this.createHeader() }); + return this.http.post>(`${this.brapiEndpoint}/search/variantsets`, searchVariantsetRequest, { headers: this.createHeader() }); } searchCallsets(searchCallsetRequest: SearchCallsetsRequest): Observable> { - return this.http.post>(`${this.baseUrl}/search/callsets`, searchCallsetRequest, { headers: this.createHeader() }); + return this.http.post>(`${this.brapiEndpoint}/search/callsets`, searchCallsetRequest, { headers: this.createHeader() }); } searchCalls(searchCallsRequest: SearchCallsRequest): Observable> { - return this.http.post>(`${this.baseUrl}/search/calls`, searchCallsRequest, { headers: this.createHeader() }); + return this.http.post>(`${this.brapiEndpoint}/search/calls`, searchCallsRequest, { headers: this.createHeader() }); } searchSamples(searchSamplesRequest: SearchSamplesRequest): Observable> { - return this.http.post>(`${this.baseUrl}/search/samples`, searchSamplesRequest, { headers: this.createHeader() }); + return this.http.post>(`${this.brapiEndpoint}/search/samples`, searchSamplesRequest, { headers: this.createHeader() }); + } + + exportFlapjack(exportRequest: ExportFlapjackRequest): Observable { + return this.http.post(`${this.baseUrl}/rest/gigwa/exportData`, exportRequest, {headers: this.createHeader(), responseType: 'text' as 'json'}); } // FIXME: Find a way to have a separate instance of HttpClient with its own HttpInterceptor diff --git a/src/main/jhipster/src/main/webapp/app/shared/crop/model/crop-genotyping-parameter.ts b/src/main/jhipster/src/main/webapp/app/shared/crop/model/crop-genotyping-parameter.ts index 5024fcf5ed..af85e0d900 100644 --- a/src/main/jhipster/src/main/webapp/app/shared/crop/model/crop-genotyping-parameter.ts +++ b/src/main/jhipster/src/main/webapp/app/shared/crop/model/crop-genotyping-parameter.ts @@ -5,7 +5,8 @@ export class CropGenotypingParameter { public tokenEndpoint: string, public userName: string, public password: string, - public programId: string + public programId: string, + public baseUrl: string ) { } } diff --git a/src/main/jhipster/yarn.lock b/src/main/jhipster/yarn.lock index 00fce889b1..a8298eefce 100644 --- a/src/main/jhipster/yarn.lock +++ b/src/main/jhipster/yarn.lock @@ -957,6 +957,13 @@ aws4@^1.2.1, aws4@^1.8.0: version "1.9.1" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.9.1.tgz#7e33d8f7d449b3f673cd72deb9abdc552dbe528e" +axios@^0.19.0: + version "0.19.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" + integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA== + dependencies: + follow-redirects "1.5.10" + axios@^0.21.1: version "0.21.1" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" @@ -3453,6 +3460,13 @@ debug@2.6.8: dependencies: ms "2.0.0" +debug@=3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^3.0.0, debug@^3.1.0, debug@^3.1.1: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" @@ -4651,6 +4665,13 @@ first-chunk-stream@^2.0.0: dependencies: readable-stream "^2.0.2" +"flapjack-bytes@git+https://github.com/cropgeeks/flapjack-bytes.git": + version "0.1.0" + resolved "git+https://github.com/cropgeeks/flapjack-bytes.git#0f0283c6118b2a03c28309aeb5e91fda1215ee05" + dependencies: + axios "^0.19.0" + node-interval-tree "^1.3.3" + flatten@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.3.tgz#c1283ac9f27b368abc1e36d1ff7b04501a30356b" @@ -4667,6 +4688,13 @@ flush-write-stream@^1.0.0: inherits "^2.0.3" readable-stream "^2.3.6" +follow-redirects@1.5.10: + version "1.5.10" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== + dependencies: + debug "=3.1.0" + follow-redirects@^1.0.0: version "1.9.0" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.9.0.tgz#8d5bcdc65b7108fe1508649c79c12d732dcedb4f" @@ -7617,6 +7645,13 @@ node-forge@0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579" +node-interval-tree@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/node-interval-tree/-/node-interval-tree-1.3.3.tgz#15ffb904cde08270214acace8dc7653e89ae32b7" + integrity sha512-K9vk96HdTK5fEipJwxSvIIqwTqr4e3HRJeJrNxBSeVMNSC/JWARRaX7etOLOuTmrRMeOI/K5TCJu3aWIwZiNTw== + dependencies: + shallowequal "^1.0.2" + node-libs-browser@^2.0.0: version "2.2.1" resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425" @@ -9911,6 +9946,11 @@ shallow-clone@^3.0.0: dependencies: kind-of "^6.0.2" +shallowequal@^1.0.2: + version "1.1.0" + resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8" + integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ== + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" diff --git a/src/main/web/yarn.lock b/src/main/web/yarn.lock index 70d46eb2a6..62b4a8cede 100644 --- a/src/main/web/yarn.lock +++ b/src/main/web/yarn.lock @@ -2599,9 +2599,9 @@ braces@~3.0.2: dependencies: fill-range "^7.0.1" -"brapi-sync@git+ssh://git@github.com/IntegratedBreedingPlatform/brapi-sync.git#semver:1.4.0": - version "1.4.0" - resolved "git+ssh://git@github.com/IntegratedBreedingPlatform/brapi-sync.git#c8f7344c25678c2d3207c5422cadb00e42eb96bb" +"brapi-sync@git+ssh://git@github.com/IntegratedBreedingPlatform/brapi-sync.git#semver:1.5.0": + version "1.5.0" + resolved "git+ssh://git@github.com/IntegratedBreedingPlatform/brapi-sync.git#662b33e223403df5459584612b7335903252163c" dependencies: "@angular/animations" "~11.2.4" "@angular/common" "~11.2.4"