Skip to content

Commit

Permalink
Merge pull request #754 from IntegratedBreedingPlatform/IBP-5656-Flap…
Browse files Browse the repository at this point in the history
…jackBytesIntegration

IBP-5656-FlapjackBytesIntegration
  • Loading branch information
abatac authored Sep 21, 2022
2 parents 0120a85 + dde1527 commit 46cb55a
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 84 deletions.
1 change: 1 addition & 0 deletions src/main/jhipster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,54 +98,12 @@
</form>
<hr>
<div class="row">
<div class="col-md-8">
<span *ngIf="isGenotypingCallsLoading" class="throbber"></span>
<div class="table-responsive">
<table class="table table-striped table-bordered table-curved" *ngIf="genotypingCalls && genotypingCalls.length else nodata">
<thead>
<tr>
<th jhiTranslate="genotyping.calls.table.marker.column">Marker</th>
<th jhiTranslate="genotyping.calls.table.genotype.call.column">Genotype Call</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of genotypingCalls">
<td>{{item?.variantName}}</td>
<td>{{item?.genotype?.values[0]}}</td>
</tr>
</tbody>
</table>
</div>
<div *ngIf="genotypingCalls && genotypingCalls.length">
<div class="row">
<div class="col">
<div class="pagination-container">
<div class="pagination-box pagination-box-left"></div>
<div class="pagination-box">
<ngb-pagination [collectionSize]="totalCount" [(page)]="page" [pageSize]="pageSize" [disabled]="isGenotypingCallsLoading"
[maxSize]="5" [rotate]="true" (pageChange)="loadGenotypingCalls()"></ngb-pagination>
</div>
<div class="pagination-box pagination-box-right"></div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<span *ngIf="isExportingFlapjack" class="throbber"></span>
<div id="flapjack-div" ref="bytes"></div>
<br/>
</div>
</div>
</div>
</div>
</div>
<ng-template #nodata>
<table class="table table-striped table-bordered table-curved">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td jhiTranslate="no.data"></td>
</tr>
</tbody>
</table>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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<BrapiResponse<Study>> {
return this.http.post<BrapiResponse<Study>>(`${this.baseUrl}/search/studies`, searchStudiesRequest, { headers: this.createHeader() });
return this.http.post<BrapiResponse<Study>>(`${this.brapiEndpoint}/search/studies`, searchStudiesRequest, { headers: this.createHeader() });
}

searchGermplasm(searchGermplasmRequest: SearchGermplasmRequest): Observable<BrapiResponse<Germplasm>> {
return this.http.post<BrapiResponse<Germplasm>>(`${this.baseUrl}/search/germplasm`, searchGermplasmRequest, { headers: this.createHeader() });
return this.http.post<BrapiResponse<Germplasm>>(`${this.brapiEndpoint}/search/germplasm`, searchGermplasmRequest, { headers: this.createHeader() });
}

searchVariantsets(searchVariantsetRequest: SearchVariantsetRequest): Observable<BrapiResponse<VariantSet>> {
return this.http.post<BrapiResponse<VariantSet>>(`${this.baseUrl}/search/variantsets`, searchVariantsetRequest, { headers: this.createHeader() });
return this.http.post<BrapiResponse<VariantSet>>(`${this.brapiEndpoint}/search/variantsets`, searchVariantsetRequest, { headers: this.createHeader() });
}

searchCallsets(searchCallsetRequest: SearchCallsetsRequest): Observable<BrapiResponse<CallSet>> {
return this.http.post<BrapiResponse<CallSet>>(`${this.baseUrl}/search/callsets`, searchCallsetRequest, { headers: this.createHeader() });
return this.http.post<BrapiResponse<CallSet>>(`${this.brapiEndpoint}/search/callsets`, searchCallsetRequest, { headers: this.createHeader() });
}

searchCalls(searchCallsRequest: SearchCallsRequest): Observable<BrapiResponse<Call>> {
return this.http.post<BrapiResponse<Call>>(`${this.baseUrl}/search/calls`, searchCallsRequest, { headers: this.createHeader() });
return this.http.post<BrapiResponse<Call>>(`${this.brapiEndpoint}/search/calls`, searchCallsRequest, { headers: this.createHeader() });
}

searchSamples(searchSamplesRequest: SearchSamplesRequest): Observable<BrapiResponse<Sample>> {
return this.http.post<BrapiResponse<Germplasm>>(`${this.baseUrl}/search/samples`, searchSamplesRequest, { headers: this.createHeader() });
return this.http.post<BrapiResponse<Germplasm>>(`${this.brapiEndpoint}/search/samples`, searchSamplesRequest, { headers: this.createHeader() });
}

exportFlapjack(exportRequest: ExportFlapjackRequest): Observable<string> {
return this.http.post<string>(`${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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}
}
40 changes: 40 additions & 0 deletions src/main/jhipster/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/main/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 46cb55a

Please sign in to comment.