Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when changing annotation type when status is set #2167

Closed
AgnesBaud opened this issue May 24, 2019 · 7 comments · Fixed by #2168
Closed

Error when changing annotation type when status is set #2167

AgnesBaud opened this issue May 24, 2019 · 7 comments · Fixed by #2168
Labels
Milestone

Comments

@AgnesBaud
Copy link

Hello,

I have a problem where once an annotation have been specified a status (and even if I take the status off afterward), I can't change the feature type anymore. However, I can change the type of an annotation that have never been specified a status.
I looked a bit into the database but I didn't find any differences between the genes for which it works (status never specified) and genes for which it doesn't work (status - at least once - specified ).

When I try to change the annotation type from gene to pseudogene, I get this error message:
Capture du 2019-05-22 10-16-27
Whereas when I try to change the annotation type from pseudogene to gene, I get this error message:
Capture du 2019-05-22 16-20-39

Below, the output of this operations in the catalina.out:
ERRORS_catalina.out.pdf

Thank you in advance,

Agnès

@nathandunn nathandunn changed the title Error when changing annotation type Error when changing annotation type when status is set May 24, 2019
@nathandunn nathandunn added this to the 2.4.0 milestone May 24, 2019
@nathandunn nathandunn added the bug label May 24, 2019
@nathandunn
Copy link
Contributor

Thanks for reporting @AgnesBaud

@nathandunn
Copy link
Contributor

Note: this only happens on the transcript.

When changing on the gene I get the property:

 {"name":"orig_id","type":{"cv":{"name":"feature_property"}},"value":"GB42586-RA"}

and the property type:

  {"cv":{"name":"feature_property"}}

versus when set on the name we get the property property :

{"type":{"cv":{"name":"feature_property"}},"value":"Opened"} 

and property type:

{"cv":{"name":"feature_property"}}

In the database, they are both set the same:

 79591 |       0 |      79572 |    0 |     |         | Opened | org.bbop.apollo.Status

@nathandunn
Copy link
Contributor

nathandunn commented May 24, 2019

Changing annotation type leads to a proliferation of incorrect attributes.

image

@nathandunn
Copy link
Contributor

Part of a proposed solution:

diff --git a/grails-app/services/org/bbop/apollo/FeatureService.groovy b/grails-app/services/org/bbop/apollo/FeatureService.groovy
index 0dfc18621..769067dc2 100644
--- a/grails-app/services/org/bbop/apollo/FeatureService.groovy
+++ b/grails-app/services/org/bbop/apollo/FeatureService.groovy
@@ -1435,20 +1435,42 @@ public void setTranslationEnd(Transcript transcript, int translationEnd) {
                     gsolFeature.addToFeatureProperties(gsolProperty)
                 }
             }
+
+
+            // handle status here
+            if (jsonFeature.has(FeatureStringEnum.STATUS.value)) {
+                String propertyValue = jsonFeature.get(FeatureStringEnum.STATUS.value)
+//                String propertyValue = property.get(FeatureStringEnum.VALUE.value)
+                AvailableStatus availableStatus = AvailableStatus.findByValue(propertyValue)
+                if (availableStatus) {
+                    Status status = new Status(
+                            value: availableStatus.value,
+                            feature: gsolFeature
+                    ).save(failOnError: true)
+                    gsolFeature.status = status
+                    gsolFeature.save()
+                } else {
+                    log.warn "Ignoring status ${propertyValue} as its not defined."
+                }
+            }
+
             if (jsonFeature.has(FeatureStringEnum.PROPERTIES.value)) {
                 JSONArray properties = jsonFeature.getJSONArray(FeatureStringEnum.PROPERTIES.value);
+                println "converting properties ${properties as JSON}"
                 for (int i = 0; i < properties.length(); ++i) {
                     JSONObject property = properties.getJSONObject(i);
                     JSONObject propertyType = property.getJSONObject(FeatureStringEnum.TYPE.value);
-                    String propertyName = ""
+                    String propertyName = null
                     if (property.has(FeatureStringEnum.NAME.value)) {
                         propertyName = property.get(FeatureStringEnum.NAME.value)
-                    } else {
+                    }
+                    else
+                    if (propertyType.has(FeatureStringEnum.NAME.value)) {
                         propertyName = propertyType.get(FeatureStringEnum.NAME.value)
                     }
                     String propertyValue = property.get(FeatureStringEnum.VALUE.value)
 
-                    FeatureProperty gsolProperty = null;
+                    FeatureProperty gsolProperty = null
                     if (propertyName == FeatureStringEnum.STATUS.value) {
                         // property of type 'Status'
                         AvailableStatus availableStatus = AvailableStatus.findByValue(propertyValue)
@@ -1462,7 +1484,8 @@ public void setTranslationEnd(Transcript transcript, int translationEnd) {
                         } else {
                             log.warn "Ignoring status ${propertyValue} as its not defined."
                         }
-                    } else {
+                    } else
+                    if (propertyName) {
                         if (propertyName == FeatureStringEnum.COMMENT.value) {
                             // property of type 'Comment'
                             gsolProperty = new Comment();

@nathandunn
Copy link
Contributor

nathandunn commented May 24, 2019

Multiple problems to fix. These all stem from the fact that the status is coming through the properties improperly.

  • changing annotation type locks up with the above error if the status is on the transcript
  • changing annotation type when on the top-level gene / pseudogene adds a property

The fix above actually works perfectly for transcript. Need to make the same for the gene.

@nathandunn
Copy link
Contributor

@AgnesBaud this should be working in the development branch now.

Thanks for reporting.

@AgnesBaud
Copy link
Author

It works perfectly. Thank you @nathandunn !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants