Browse code

update after bioconductor review

Veronica Paparozzi authored on 05/09/2024 14:11:20
Showing 1 changed files
... ...
@@ -7,24 +7,24 @@
7 7
 # @param descriptor_content_idx index for creator's content, an integer
8 8
 #
9 9
 # @return value for creator's content, a character string
10
-as_value.annotation.creator <- function(list_creator=list_app, vec_value_i=vec_tmp_i, descriptor_content_idx=m){
11
-  if(descriptor_content_idx!=1) vec_value_i <- paste(vec_value_i, "||", sep = "")
10
+as_value.annotation.creator <- function(list_creator = list_app, vec_value_i = vec_tmp_i, descriptor_content_idx = m) {
11
+  if (descriptor_content_idx != 1) vec_value_i <- paste(vec_value_i, "||", sep = "")
12 12
 
13
-  for(p in seq_along(list_creator[[descriptor_content_idx]])){
14
-    str_name <- attributes(list_creator[[descriptor_content_idx]])[["names"]][[p]]   # N,ORG,EMAIL
13
+  for (p in seq_along(list_creator[[descriptor_content_idx]])) {
14
+    str_name <- attributes(list_creator[[descriptor_content_idx]])[["names"]][[p]] # N,ORG,EMAIL
15 15
     sub_names <- names(list_creator[[descriptor_content_idx]][[p]])
16 16
 
17
-    if(descriptor_content_idx!=1||p!=1){
18
-      if(p!=1) vec_value_i=paste(vec_value_i, "; ", sep = "")
19
-      vec_value_i <- paste(vec_value_i,str_name,"(",paste(sub_names, collapse=" "),"):", sep = "")
20
-    }else{
21
-      vec_value_i <- paste(str_name,"(",paste(sub_names, collapse=" "),"):", sep = "")
17
+    if (descriptor_content_idx != 1 || p != 1) {
18
+      if (p != 1) vec_value_i <- paste(vec_value_i, "; ", sep = "")
19
+      vec_value_i <- paste(vec_value_i, str_name, "(", paste(sub_names, collapse = " "), "):", sep = "")
20
+    } else {
21
+      vec_value_i <- paste(str_name, "(", paste(sub_names, collapse = " "), "):", sep = "")
22 22
     }
23 23
 
24
-    for(q in seq_along(list_creator[[descriptor_content_idx]][[p]])){
25
-      if(length(list_creator[[descriptor_content_idx]][[p]][[q]])==0) {
24
+    for (q in seq_along(list_creator[[descriptor_content_idx]][[p]])) {
25
+      if (length(list_creator[[descriptor_content_idx]][[p]][[q]]) == 0) {
26 26
         vec_value_i <- paste(vec_value_i, " , ", sep = " ")
27
-      }else{
27
+      } else {
28 28
         vec_value_i <- paste(vec_value_i, list_creator[[descriptor_content_idx]][[p]][[q]][[1]][[1]], sep = " ")
29 29
       }
30 30
     }
... ...
@@ -42,111 +42,95 @@ as_value.annotation.creator <- function(list_creator=list_app, vec_value_i=vec_t
42 42
 # @param sep delimiter to be used to separate multiple values associated to only one entity, a character string
43 43
 #
44 44
 # @return value contained inside one annotation descriptor tag, a character string
45
-as_value.annotation <- function(list_annotation_descriptor, vec_tmp_i, sep = "||"){
46
-
47
-  if(length(list_annotation_descriptor)==1 && names(list_annotation_descriptor)=="W3CDTF"){
48
-    if(length(list_annotation_descriptor[[1]])==1){
45
+as_value.annotation <- function(list_annotation_descriptor, vec_tmp_i, sep = " ") {
46
+  if (length(list_annotation_descriptor) == 1 && names(list_annotation_descriptor) == "W3CDTF") {
47
+    if (length(list_annotation_descriptor[[1]]) == 1) {
49 48
       vec_tmp_i <- list_annotation_descriptor[[1]][[1]]
50
-    }else{
51
-      vec_tmp_i <- paste(list_annotation_descriptor[[1]][[1]], " and other elements", sep="")
49
+    } else {
50
+      vec_tmp_i <- paste(list_annotation_descriptor[[1]][[1]], " and other elements", sep = "")
52 51
     }
53
-  }else if(length(list_annotation_descriptor)==1 && names(list_annotation_descriptor) %in% c("Bag","Seq","Alt")){
54
-    if(length(list_annotation_descriptor[[1]])==0){ # case with empty Bag/Seq/Alt
55
-      vec_tmp_i <- paste("Empty",names(list_annotation_descriptor), seq=" ")
56
-    }else{
52
+  } else if (length(list_annotation_descriptor) == 1 && names(list_annotation_descriptor) %in% c("Bag", "Seq", "Alt")) {
53
+    if (length(list_annotation_descriptor[[1]]) == 0) { # case with empty Bag/Seq/Alt
54
+      vec_tmp_i <- paste("Empty", names(list_annotation_descriptor), seq = " ")
55
+    } else {
57 56
       list_app <- list_annotation_descriptor[[1]]
58 57
 
59
-      for(m in seq_along(list_app)){
60
-
61
-        if(length(list_app[[m]])==0){
62
-          if(m==1){
58
+      for (m in seq_along(list_app)) {
59
+        if (length(list_app[[m]]) == 0) {
60
+          if (m == 1) {
63 61
             vec_tmp_i <- attributes(list_app[[m]])[[1]]
64
-          }else{
65
-            vec_tmp_i <- paste(vec_tmp_i,attributes(list_app[[m]])[[1]], sep = sep)
62
+          } else {
63
+            vec_tmp_i <- paste(vec_tmp_i, attributes(list_app[[m]])[[1]], sep = sep)
66 64
           }
67
-        }else{
65
+        } else {
68 66
           vec_tmp_i <- as_value.annotation.creator(list_app, vec_tmp_i, m)
69 67
         }
70 68
       }
71 69
     }
72
-  }else{
73
-    vec_tmp_i <- "ERROR"
70
+  } else {
71
+    vec_tmp_i <- "Extraction not available"
74 72
     warning("Extraction of 'annotation' not available : different case for descriptor's extraction (neither 'W3CDTF' nor 'Bag'/'Seq'/'Alt' element)")
75 73
   }
76 74
   vec_tmp_i
77 75
 }
78 76
 
79 77
 
80
-#' Create a dataframe with annotation content
81
-#'
82
-#' It returns a dataframe with one row for each entity and 0 or more columns. If zero, it means the annotation content for each entity inside the 'listOf' selected is empty.
83
-#'
84
-#' Each column is named as 'annotation_' concatenated with the 'descriptor name' (e.g. is, hasPart, isVersionOf). If the name is repeated (i.e. there are multiple equal descriptors' name for the same entity), it concatenates also a number to the name, starting from '_1' and leaving the first name without any number.
85
-#'
86
-#' @param sbml_list_listOf sbml-converted list restricted to a 'listOf' level (e.g. listOfSpecies), a list
87
-#'
88
-#' @return one data frame with one row for each entity inside the 'listOf' selected and one column for each annotation's descriptor reported for them.  Empty vector if the 'annotation' content is empty for each entity.
89
-#' @export
90
-#'
91
-#' @examples
92
-#' sbml_list <- sbml_as_list(system.file("extdata", "R-HSA-8937144.sbml", package = "tidysbml"), "species")
93
-#' df <- as_df.annotation(sbml_list)  ## returns one dataframe with one row for each species and one column for each descriptor in annotation
94
-as_df.annotation <- function(sbml_list_listOf){
95
-
96
-  # Check input conditions:
97
-  if(missing(sbml_list_listOf)) stop("no argument inserted. You must provide one list in input.")
98
-  if(!typeof(sbml_list_listOf)=="list") stop("argument is not a list")
99
-  len=length(sbml_list_listOf)
100
-  if(!len) stop("Empty output : list of length 0 inserted")
101
-  if(length(unique(names(sbml_list_listOf)))!=1 && !unique(names(sbml_list_listOf)) %in% c("species", "reaction", "compartment")) stop("invalid format for list in input : it must contain only one type of element, that is either 'species','reaction' or 'compartment' type")
102
-
78
+# Create a dataframe with annotation content
79
+#
80
+# It returns a dataframe with one row for each entity and 0 or more columns. If zero, it means the annotation content for each entity inside the 'listOf' selected is empty.
81
+#
82
+# Each column is named as 'annotation_' concatenated with the 'descriptor name' (e.g. is, hasPart, isVersionOf). If the name is repeated (i.e. there are multiple equal descriptors' name for the same entity), it concatenates also a number to the name, starting from '_1' and leaving the first name without any number.
83
+#
84
+# @param sbml_list_listOf sbml-converted list restricted to a 'listOf' level (e.g. listOfSpecies), a list
85
+#
86
+# @return one data frame with one row for each entity inside the 'listOf' selected and one column for each annotation's descriptor reported for them.  Empty vector if the 'annotation' content is empty for each entity.
87
+#
88
+# @examples
89
+# sbml_list <- sbml_as_list(system.file("extdata", "R-HSA-8937144.sbml", package = "tidysbml"), "species")
90
+# df <- as_df.annotation(sbml_list)  ## returns one dataframe with one row for each species and one column for each descriptor in annotation
91
+as_df.annotation <- function(sbml_list_listOf) {
103 92
   vec_names_attr <- c()
104 93
   vec_annotation <- c()
105 94
   vec_colname_annotation <- c()
106 95
   vec_colname_ann_final <- c()
107 96
 
108
-  for (i in seq_len(len)) {
109
-    for(j in seq_along(names(sbml_list_listOf[[i]]))){
110
-
111
-      if(names(sbml_list_listOf[[i]])[j]=="annotation"){
112
-        if(length(sbml_list_listOf[[i]][[j]])>0){
113
-
97
+  for (i in seq_along(sbml_list_listOf)) {
98
+    for (j in seq_along(names(sbml_list_listOf[[i]]))) {
99
+      if (names(sbml_list_listOf[[i]])[j] == "annotation") {
100
+        if (length(sbml_list_listOf[[i]][[j]]) > 0) {
114 101
           vec_names_descriptor <- c()
115 102
 
116
-          for(k in seq_along(sbml_list_listOf[[i]][[j]])){
117
-
118
-            if(length(sbml_list_listOf[[i]][[j]][[k]])>0){
119
-
120
-              if(names(sbml_list_listOf[[i]][[j]])[k]=="RDF"){   # case with 'RDF'
103
+          for (k in seq_along(sbml_list_listOf[[i]][[j]])) {
104
+            if (length(sbml_list_listOf[[i]][[j]][[k]]) > 0) {
105
+              if (names(sbml_list_listOf[[i]][[j]])[k] == "RDF") { # case with 'RDF'
121 106
 
122
-                for(n_descr in seq_along(sbml_list_listOf[[i]][[j]][[k]])){
123
-
124
-                  if(names(sbml_list_listOf[[i]][[j]][[k]])[n_descr]=="Description"){
107
+                for (n_descr in seq_along(sbml_list_listOf[[i]][[j]][[k]])) {
108
+                  if (names(sbml_list_listOf[[i]][[j]][[k]])[n_descr] == "Description") {
125 109
                     list_temp <- sbml_list_listOf[[i]][[j]][[k]][[n_descr]]
126 110
 
127
-                    for(l in seq_along(list_temp)){
111
+                    for (l in seq_along(list_temp)) {
128 112
                       # create one column for each name in Description
129 113
                       name_descriptor <- names(list_temp)[l]
130
-                      name_col_descriptor <- paste("annotation_", name_descriptor ,"__",sep="")
114
+                      name_col_descriptor <- paste("annotation_", name_descriptor, "__", sep = "")
131 115
 
132
-                      name_col_tosearch <- substr(name_col_descriptor, 1, nchar(name_col_descriptor)-1)
133
-                      name_col_tosave <- substr(name_col_descriptor, 1, nchar(name_col_descriptor)-2)
116
+                      name_col_tosearch <- substr(name_col_descriptor, 1, nchar(name_col_descriptor) - 1)
117
+                      name_col_tosave <- substr(name_col_descriptor, 1, nchar(name_col_descriptor) - 2)
134 118
 
135
-                      if(!name_col_descriptor %in% vec_colname_annotation ){
136
-                        assign(name_col_descriptor, rep(NA,length(sbml_list_listOf)) )
119
+                      if (!name_col_descriptor %in% vec_colname_annotation) {
120
+                        assign(name_col_descriptor, rep(NA, length(sbml_list_listOf)))
137 121
                         vec_colname_ann_final <- c(vec_colname_ann_final, name_col_tosave)
138 122
                         vec_colname_annotation <- c(vec_colname_annotation, name_col_descriptor)
139 123
                         vec_names_descriptor <- c(vec_names_descriptor, name_col_descriptor)
140
-                      }else if(!name_col_descriptor %in% vec_names_descriptor){
124
+                      } else if (!name_col_descriptor %in% vec_names_descriptor) {
141 125
                         vec_names_descriptor <- c(vec_names_descriptor, name_col_descriptor)
142
-                      }else{  # case with name repeated
143
-                        string_tosearch <- paste("^",name_col_tosearch,".+", sep = "")
126
+                      } else { # case with name repeated
127
+                        string_tosearch <- paste("^", name_col_tosearch, ".+", sep = "")
144 128
                         number <- sum(grepl(string_tosearch, vec_names_descriptor))
145 129
                         name_new_col <- paste(name_col_tosearch, number, sep = "")
146
-                        if(name_new_col %in% vec_colname_annotation){
130
+                        if (name_new_col %in% vec_colname_annotation) {
147 131
                           vec_names_descriptor <- c(vec_names_descriptor, name_new_col)
148
-                        }else{
149
-                          assign(name_new_col , rep(NA,length(sbml_list_listOf)) )
132
+                        } else {
133
+                          assign(name_new_col, rep(NA, length(sbml_list_listOf)))
150 134
                           vec_colname_ann_final <- c(vec_colname_ann_final, name_new_col)
151 135
                           vec_colname_annotation <- c(vec_colname_annotation, name_new_col)
152 136
                           vec_names_descriptor <- c(vec_names_descriptor, name_new_col)
... ...
@@ -156,42 +140,39 @@ as_df.annotation <- function(sbml_list_listOf){
156 140
 
157 141
                       list_temp1 <- list_temp[[l]]
158 142
 
159
-                      # fill with value
143
+                      # insert value
160 144
                       vec_app <- get(name_col_descriptor)
161
-                      if(!is.null(as_value.annotation(list_temp1, vec_app[i]))){ # returns NA otherwise
145
+                      if (!is.null(as_value.annotation(list_temp1, vec_app[i]))) { # returns NA otherwise
162 146
                         vec_app[i] <- as_value.annotation(list_temp1, vec_app[i])
163 147
                       }
164 148
 
165
-                      assign(name_col_descriptor,vec_app)
166
-
149
+                      assign(name_col_descriptor, vec_app)
167 150
                     }
168 151
                   }
169 152
                 }
170
-
171
-              }else{ #case different from 'RDF' within annotation
172
-                warning("Extraction of 'annotation' is not totally available for '",names(sbml_list_listOf)[i]," ",i,"': found element '",names(sbml_list_listOf[[i]][[j]])[k],"' different from 'RDF' within the input list")
153
+              } else { # case different from 'RDF' within annotation
154
+                warning("Extraction of 'annotation' is not totally available for '", names(sbml_list_listOf)[i], " ", i, "': found element '", names(sbml_list_listOf[[i]][[j]])[k], "' different from 'RDF' within the input list")
173 155
               }
174 156
             }
175 157
           }
176 158
         }
177 159
       }
178
-
179 160
     }
180 161
   }
181 162
 
182
-  if(length(vec_colname_ann_final)==length(vec_colname_annotation) && length(vec_colname_annotation)){
163
+  if (length(vec_colname_ann_final) == length(vec_colname_annotation) && length(vec_colname_annotation)) {
183 164
     vec_colname_ann_final <- sort(vec_colname_ann_final)
184 165
     vec_colname_annotation <- sort(vec_colname_annotation)
185
-    df=data.frame(
166
+    df <- data.frame(
186 167
       lapply(
187 168
         seq_along(vec_colname_annotation),
188
-        function(n_col)  get(vec_colname_annotation[n_col])
169
+        function(n_col) get(vec_colname_annotation[n_col])
189 170
       )
190 171
     )
191 172
     colnames(df) <- vec_colname_ann_final
192 173
     df
193
-  }else{
194
-    message("Empty annotation's columns for '", unique(names(sbml_list_listOf)) ,"' elements")
174
+  } else {
175
+    message("Empty annotation's columns for '", unique(names(sbml_list_listOf)), "' elements")
195 176
     c()
196 177
   }
197 178
 }
Browse code

add files to local repo

veronicapaparozzi authored on 24/02/2024 18:29:58
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,197 @@
1
+# Character value inside annotation creator
2
+#
3
+# Helper function for as_value.annotation(). It returns the content for descriptors with nested content (i.e. creator).
4
+#
5
+# @param list_creator sbml-converted list looking at 'creator' tag level, a list
6
+# @param vec_value_i value to be inserted in the annotation_creator column for the i-th entity, a character string
7
+# @param descriptor_content_idx index for creator's content, an integer
8
+#
9
+# @return value for creator's content, a character string
10
+as_value.annotation.creator <- function(list_creator=list_app, vec_value_i=vec_tmp_i, descriptor_content_idx=m){
11
+  if(descriptor_content_idx!=1) vec_value_i <- paste(vec_value_i, "||", sep = "")
12
+
13
+  for(p in seq_along(list_creator[[descriptor_content_idx]])){
14
+    str_name <- attributes(list_creator[[descriptor_content_idx]])[["names"]][[p]]   # N,ORG,EMAIL
15
+    sub_names <- names(list_creator[[descriptor_content_idx]][[p]])
16
+
17
+    if(descriptor_content_idx!=1||p!=1){
18
+      if(p!=1) vec_value_i=paste(vec_value_i, "; ", sep = "")
19
+      vec_value_i <- paste(vec_value_i,str_name,"(",paste(sub_names, collapse=" "),"):", sep = "")
20
+    }else{
21
+      vec_value_i <- paste(str_name,"(",paste(sub_names, collapse=" "),"):", sep = "")
22
+    }
23
+
24
+    for(q in seq_along(list_creator[[descriptor_content_idx]][[p]])){
25
+      if(length(list_creator[[descriptor_content_idx]][[p]][[q]])==0) {
26
+        vec_value_i <- paste(vec_value_i, " , ", sep = " ")
27
+      }else{
28
+        vec_value_i <- paste(vec_value_i, list_creator[[descriptor_content_idx]][[p]][[q]][[1]][[1]], sep = " ")
29
+      }
30
+    }
31
+  }
32
+  vec_value_i
33
+}
34
+
35
+
36
+# Character value inside one annotation descriptor
37
+#
38
+# Helper function for as_df.annotation(). It returns the value containing one annotation info to be inserted in one cell within the data frame.
39
+#
40
+# @param list_annotation_descriptor sbml-converted list looking at one annotation's descriptor level, a list
41
+# @param vec_tmp_i value to be inserted in the annotation_descriptorname column for the i-th entity, a character string
42
+# @param sep delimiter to be used to separate multiple values associated to only one entity, a character string
43
+#
44
+# @return value contained inside one annotation descriptor tag, a character string
45
+as_value.annotation <- function(list_annotation_descriptor, vec_tmp_i, sep = "||"){
46
+
47
+  if(length(list_annotation_descriptor)==1 && names(list_annotation_descriptor)=="W3CDTF"){
48
+    if(length(list_annotation_descriptor[[1]])==1){
49
+      vec_tmp_i <- list_annotation_descriptor[[1]][[1]]
50
+    }else{
51
+      vec_tmp_i <- paste(list_annotation_descriptor[[1]][[1]], " and other elements", sep="")
52
+    }
53
+  }else if(length(list_annotation_descriptor)==1 && names(list_annotation_descriptor) %in% c("Bag","Seq","Alt")){
54
+    if(length(list_annotation_descriptor[[1]])==0){ # case with empty Bag/Seq/Alt
55
+      vec_tmp_i <- paste("Empty",names(list_annotation_descriptor), seq=" ")
56
+    }else{
57
+      list_app <- list_annotation_descriptor[[1]]
58
+
59
+      for(m in seq_along(list_app)){
60
+
61
+        if(length(list_app[[m]])==0){
62
+          if(m==1){
63
+            vec_tmp_i <- attributes(list_app[[m]])[[1]]
64
+          }else{
65
+            vec_tmp_i <- paste(vec_tmp_i,attributes(list_app[[m]])[[1]], sep = sep)
66
+          }
67
+        }else{
68
+          vec_tmp_i <- as_value.annotation.creator(list_app, vec_tmp_i, m)
69
+        }
70
+      }
71
+    }
72
+  }else{
73
+    vec_tmp_i <- "ERROR"
74
+    warning("Extraction of 'annotation' not available : different case for descriptor's extraction (neither 'W3CDTF' nor 'Bag'/'Seq'/'Alt' element)")
75
+  }
76
+  vec_tmp_i
77
+}
78
+
79
+
80
+#' Create a dataframe with annotation content
81
+#'
82
+#' It returns a dataframe with one row for each entity and 0 or more columns. If zero, it means the annotation content for each entity inside the 'listOf' selected is empty.
83
+#'
84
+#' Each column is named as 'annotation_' concatenated with the 'descriptor name' (e.g. is, hasPart, isVersionOf). If the name is repeated (i.e. there are multiple equal descriptors' name for the same entity), it concatenates also a number to the name, starting from '_1' and leaving the first name without any number.
85
+#'
86
+#' @param sbml_list_listOf sbml-converted list restricted to a 'listOf' level (e.g. listOfSpecies), a list
87
+#'
88
+#' @return one data frame with one row for each entity inside the 'listOf' selected and one column for each annotation's descriptor reported for them.  Empty vector if the 'annotation' content is empty for each entity.
89
+#' @export
90
+#'
91
+#' @examples
92
+#' sbml_list <- sbml_as_list(system.file("extdata", "R-HSA-8937144.sbml", package = "tidysbml"), "species")
93
+#' df <- as_df.annotation(sbml_list)  ## returns one dataframe with one row for each species and one column for each descriptor in annotation
94
+as_df.annotation <- function(sbml_list_listOf){
95
+
96
+  # Check input conditions:
97
+  if(missing(sbml_list_listOf)) stop("no argument inserted. You must provide one list in input.")
98
+  if(!typeof(sbml_list_listOf)=="list") stop("argument is not a list")
99
+  len=length(sbml_list_listOf)
100
+  if(!len) stop("Empty output : list of length 0 inserted")
101
+  if(length(unique(names(sbml_list_listOf)))!=1 && !unique(names(sbml_list_listOf)) %in% c("species", "reaction", "compartment")) stop("invalid format for list in input : it must contain only one type of element, that is either 'species','reaction' or 'compartment' type")
102
+
103
+  vec_names_attr <- c()
104
+  vec_annotation <- c()
105
+  vec_colname_annotation <- c()
106
+  vec_colname_ann_final <- c()
107
+
108
+  for (i in seq_len(len)) {
109
+    for(j in seq_along(names(sbml_list_listOf[[i]]))){
110
+
111
+      if(names(sbml_list_listOf[[i]])[j]=="annotation"){
112
+        if(length(sbml_list_listOf[[i]][[j]])>0){
113
+
114
+          vec_names_descriptor <- c()
115
+
116
+          for(k in seq_along(sbml_list_listOf[[i]][[j]])){
117
+
118
+            if(length(sbml_list_listOf[[i]][[j]][[k]])>0){
119
+
120
+              if(names(sbml_list_listOf[[i]][[j]])[k]=="RDF"){   # case with 'RDF'
121
+
122
+                for(n_descr in seq_along(sbml_list_listOf[[i]][[j]][[k]])){
123
+
124
+                  if(names(sbml_list_listOf[[i]][[j]][[k]])[n_descr]=="Description"){
125
+                    list_temp <- sbml_list_listOf[[i]][[j]][[k]][[n_descr]]
126
+
127
+                    for(l in seq_along(list_temp)){
128
+                      # create one column for each name in Description
129
+                      name_descriptor <- names(list_temp)[l]
130
+                      name_col_descriptor <- paste("annotation_", name_descriptor ,"__",sep="")
131
+
132
+                      name_col_tosearch <- substr(name_col_descriptor, 1, nchar(name_col_descriptor)-1)
133
+                      name_col_tosave <- substr(name_col_descriptor, 1, nchar(name_col_descriptor)-2)
134
+
135
+                      if(!name_col_descriptor %in% vec_colname_annotation ){
136
+                        assign(name_col_descriptor, rep(NA,length(sbml_list_listOf)) )
137
+                        vec_colname_ann_final <- c(vec_colname_ann_final, name_col_tosave)
138
+                        vec_colname_annotation <- c(vec_colname_annotation, name_col_descriptor)
139
+                        vec_names_descriptor <- c(vec_names_descriptor, name_col_descriptor)
140
+                      }else if(!name_col_descriptor %in% vec_names_descriptor){
141
+                        vec_names_descriptor <- c(vec_names_descriptor, name_col_descriptor)
142
+                      }else{  # case with name repeated
143
+                        string_tosearch <- paste("^",name_col_tosearch,".+", sep = "")
144
+                        number <- sum(grepl(string_tosearch, vec_names_descriptor))
145
+                        name_new_col <- paste(name_col_tosearch, number, sep = "")
146
+                        if(name_new_col %in% vec_colname_annotation){
147
+                          vec_names_descriptor <- c(vec_names_descriptor, name_new_col)
148
+                        }else{
149
+                          assign(name_new_col , rep(NA,length(sbml_list_listOf)) )
150
+                          vec_colname_ann_final <- c(vec_colname_ann_final, name_new_col)
151
+                          vec_colname_annotation <- c(vec_colname_annotation, name_new_col)
152
+                          vec_names_descriptor <- c(vec_names_descriptor, name_new_col)
153
+                        }
154
+                        name_col_descriptor <- name_new_col
155
+                      }
156
+
157
+                      list_temp1 <- list_temp[[l]]
158
+
159
+                      # fill with value
160
+                      vec_app <- get(name_col_descriptor)
161
+                      if(!is.null(as_value.annotation(list_temp1, vec_app[i]))){ # returns NA otherwise
162
+                        vec_app[i] <- as_value.annotation(list_temp1, vec_app[i])
163
+                      }
164
+
165
+                      assign(name_col_descriptor,vec_app)
166
+
167
+                    }
168
+                  }
169
+                }
170
+
171
+              }else{ #case different from 'RDF' within annotation
172
+                warning("Extraction of 'annotation' is not totally available for '",names(sbml_list_listOf)[i]," ",i,"': found element '",names(sbml_list_listOf[[i]][[j]])[k],"' different from 'RDF' within the input list")
173
+              }
174
+            }
175
+          }
176
+        }
177
+      }
178
+
179
+    }
180
+  }
181
+
182
+  if(length(vec_colname_ann_final)==length(vec_colname_annotation) && length(vec_colname_annotation)){
183
+    vec_colname_ann_final <- sort(vec_colname_ann_final)
184
+    vec_colname_annotation <- sort(vec_colname_annotation)
185
+    df=data.frame(
186
+      lapply(
187
+        seq_along(vec_colname_annotation),
188
+        function(n_col)  get(vec_colname_annotation[n_col])
189
+      )
190
+    )
191
+    colnames(df) <- vec_colname_ann_final
192
+    df
193
+  }else{
194
+    message("Empty annotation's columns for '", unique(names(sbml_list_listOf)) ,"' elements")
195
+    c()
196
+  }
197
+}