Skip to content

Commit

Permalink
Fix json attribute upload (#2618)
Browse files Browse the repository at this point in the history
* fixedwith or from error

* handles only having GO annotations

* updated changelog and adds note

* minor cleanup
  • Loading branch information
nathandunn committed May 12, 2021
1 parent 9016b45 commit 5eae7d8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Features

- Added method to upload bulk functional annotations from JSON in the interface [2617](https://github.com/GMOD/Apollo/pull/2617).
- Added method to upload bulk functional annotations from JSON in the interface [2617](https://github.com/GMOD/Apollo/pull/2617),[2618](https://github.com/GMOD/Apollo/pull/2618).


## 2.6.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,9 @@ class AnnotatorController {
provenanceArrayList.add(provenance)
}

/**
* Adds history
*/

// JSONArray oldFeaturesJsonArray = new JSONArray()
// oldFeaturesJsonArray.add(originalFeatureJsonObject)
Expand Down
22 changes: 16 additions & 6 deletions src/gwt/org/bbop/apollo/gwt/client/UploadDialog.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.bbop.apollo.gwt.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.http.client.Request;
Expand Down Expand Up @@ -47,6 +46,9 @@ public class UploadDialog extends Modal {
" \"gene_product\": [{\"notes\":\"[\\\"Sample\\\"]\",\"evidenceCodeLabel\":\"IBA (ECO:0000318): inferred from biological aspect of ancestor\",\"alternate\":true,\"evidenceCode\":\"ECO:0000318\",\"id\":1,\"productName\":\"AQP1\"},{\"reference\":\"PMID:21873635\",\"notes\":\"[]\",\"evidenceCodeLabel\":\"IBA (ECO:0000318): inferred from biological aspect of ancestor\",\"alternate\":false,\"evidenceCode\":\"ECO:0000318\",\"id\":2,\"productName\":\"FAM20A\"}],\n" +
" \"provenance\": [{\"notes\":\"[]\",\"field\":\"TYPE\",\"evidenceCodeLabel\":\"HDA (ECO:0007005): inferred from high throughput direct assay\",\"evidenceCode\":\"ECO:0007005\",\"id\":1},{\"reference\":\"PMID:79972\",\"notes\":\"[\\\"test\\\",\\\"note\\\"]\",\"field\":\"SYNONYM\",\"evidenceCodeLabel\":\"IEP (ECO:0000270): inferred from expression pattern\",\"evidenceCode\":\"ECO:0000270\",\"id\":2}]\n" +
"}" ;
final String EXAMPLE_ANNOTATION_GO_ONLY= "{" +
" \"go_annotations\":[{\"geneRelationship\":\"RO:0002331\",\"goTerm\":\"GO:1901560\",\"notes\":\"[\\\"ExampleNote2\\\",\\\"ExampleNote1\\\"]\",\"evidenceCodeLabel\":\"HDA (ECO:0007005): inferred from high throughput direct assay\",\"negate\":false,\"aspect\":\"BP\",\"goTermLabel\":\"response to purvalanol A (GO:1901560) \",\"evidenceCode\":\"ECO:0007005\",\"id\":1},{\"reference\":\"PMID:Example\",\"geneRelationship\":\"RO:0002327\",\"goTerm\":\"GO:0051018\",\"notes\":\"[\\\"ExampleNote\\\"]\",\"evidenceCodeLabel\":\"TAS (ECO:0000304): traceable author statement\",\"negate\":false,\"aspect\":\"MF\",\"goTermLabel\":\"protein kinase A binding (GO:0051018) \",\"evidenceCode\":\"ECO:0000304\",\"id\":2}]\n" +
"}" ;

public UploadDialog(final AnnotationInfo annotationInfo) {
setSize(ModalSize.LARGE);
Expand Down Expand Up @@ -74,14 +76,22 @@ public void onClick(ClickEvent event) {
}
});
modalHeader.add(exampleLink);
Button exampleLinkEmptyRef = new Button("Example Annotation Empty Ref");
Button exampleLinkEmptyRef = new Button("Example Empty Reference");
exampleLinkEmptyRef.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textArea.setText(EXAMPLE_ANNOTATION_EMPTY_REF);
}
});
modalHeader.add(exampleLinkEmptyRef);
Button exampleLinkGoOnly= new Button("Example GO Only");
exampleLinkGoOnly.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textArea.setText(EXAMPLE_ANNOTATION_GO_ONLY);
}
});
modalHeader.add(exampleLinkGoOnly);


Button applyAnnotationsButton = new Button("Apply Annotations");
Expand All @@ -95,14 +105,14 @@ public void onClick(ClickEvent event) {
public void callback(boolean result) {
if(result){
JSONObject annotationsObject = JSONParser.parseStrict(textArea.getText()).isObject();
JSONArray goAnnotations = annotationsObject.get(FeatureStringEnum.GO_ANNOTATIONS.getValue()).isArray();

JSONArray goAnnotations = annotationsObject.containsKey(FeatureStringEnum.GO_ANNOTATIONS.getValue()) ?annotationsObject.get(FeatureStringEnum.GO_ANNOTATIONS.getValue()).isArray() : new JSONArray();
List<GoAnnotation> goAnnotationList = GoRestService.generateGoAnnotations(annotationInfo,goAnnotations);

JSONArray geneProducts = annotationsObject.get(FeatureStringEnum.GENE_PRODUCT.getValue()).isArray();
JSONArray geneProducts = annotationsObject.containsKey(FeatureStringEnum.GENE_PRODUCT.getValue()) ? annotationsObject.get(FeatureStringEnum.GENE_PRODUCT.getValue()).isArray() : new JSONArray();
List<GeneProduct> geneProductList = GeneProductRestService.generateGeneProducts(annotationInfo,geneProducts);


JSONArray provenances = annotationsObject.get(FeatureStringEnum.PROVENANCE.getValue()).isArray();
JSONArray provenances = annotationsObject.containsKey(FeatureStringEnum.PROVENANCE.getValue()) ? annotationsObject.get(FeatureStringEnum.PROVENANCE.getValue()).isArray() : new JSONArray();
List<Provenance> provenanceList = ProvenanceRestService.generateProvenances(annotationInfo,provenances);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public static List<GeneProduct> generateGeneProducts(AnnotationInfo annotationIn
}
geneProduct.setNoteList(notesList);
geneProductList.add(geneProduct);
// GeneProductRestService.saveGeneProduct(requestCallback, geneProduct);
}
return geneProductList;
}
Expand Down
7 changes: 2 additions & 5 deletions src/gwt/org/bbop/apollo/gwt/client/rest/GoRestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,13 @@ public static List<GoAnnotation> generateGoAnnotations(AnnotationInfo annotation
}
}
else{
String jsonString = "["+Reference.UNKNOWN + ":" + Reference.NOT_PROVIDED +"]";
String jsonString = Reference.UNKNOWN + ":" + Reference.NOT_PROVIDED;
withOrFromList.add(new WithOrFrom(jsonString));

}
goAnnotation.setWithOrFromList(withOrFromList);






List<String> notesList = new ArrayList<>();
JSONArray notesJsonArray = goAnnotationObject.get("notes").isArray();
if(notesJsonArray==null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public static List<Provenance> generateProvenances(AnnotationInfo annotationInfo
notesList.add(notesJsonArray.get(j).isString().stringValue());
}
provenance.setNoteList(notesList);
// ProvenanceRestService.saveProvenance(requestCallback, provenance);
provenanceList.add(provenance);
}
return provenanceList;
Expand Down

0 comments on commit 5eae7d8

Please sign in to comment.