@@ -109,6 +109,9 @@ var Dbxref = dbxref.Dbxref;
109
109
var age = ( result [ 'age' ] && result [ 'age' ] != 'unknown' ) ? ' ' + result [ 'age' ] : '' ;
110
110
var ageUnits = ( result [ 'age_units' ] && result [ 'age_units' ] != 'unknown' && age ) ? ' ' + result [ 'age_units' ] : '' ;
111
111
var separator = ( lifeStage || age ) ? ',' : '' ;
112
+ var rnais = ( result . rnais [ 0 ] && result . rnais [ 0 ] . target && result . rnais [ 0 ] . target . label ) ? result . rnais [ 0 ] . target . label : '' ;
113
+ var constructs = ( result . constructs [ 0 ] && result . constructs [ 0 ] . target && result . constructs [ 0 ] . target . label ) ? result . constructs [ 0 ] . target . label : '' ;
114
+ var treatment = ( result . treatments [ 0 ] && result . treatments [ 0 ] . treatment_term_name ) ? result . treatments [ 0 ] . treatment_term_name : '' ;
112
115
return ( < li >
113
116
< div >
114
117
{ this . renderActions ( ) }
@@ -127,22 +130,22 @@ var Dbxref = dbxref.Dbxref;
127
130
</ div >
128
131
< div className = "data-row" >
129
132
< div > < strong > { columns [ 'biosample_type' ] [ 'title' ] } </ strong > : { result [ 'biosample_type' ] } </ div >
130
- { result [ ' rnais.target.label' ] ?
133
+ { rnais ?
131
134
< div >
132
135
< strong > { columns [ 'rnais.target.label' ] [ 'title' ] + ': ' } </ strong >
133
- { result [ ' rnais.target.label' ] }
136
+ { rnais }
134
137
</ div >
135
138
: null }
136
- { result [ ' constructs.target.label' ] ?
139
+ { constructs ?
137
140
< div >
138
141
< strong > { columns [ 'constructs.target.label' ] [ 'title' ] + ': ' } </ strong >
139
- { result [ ' constructs.target.label' ] }
142
+ { constructs }
140
143
</ div >
141
144
: null }
142
- { result [ 'treatments.treatment_term_name' ] ?
145
+ { treatment ?
143
146
< div >
144
147
< strong > { columns [ 'treatments.treatment_term_name' ] [ 'title' ] + ': ' } </ strong >
145
- { result [ 'treatments.treatment_term_name' ] }
148
+ { treatment }
146
149
</ div >
147
150
: null }
148
151
< div > < strong > { columns [ 'source.title' ] [ 'title' ] } </ strong > : { result [ 'source.title' ] } </ div >
@@ -154,47 +157,90 @@ var Dbxref = dbxref.Dbxref;
154
157
globals . listing_views . register ( Biosample , 'biosample' ) ;
155
158
156
159
157
- // Returns array length if array 'a' with 1st index 'i' contains all same non-'unknown' value in its 2nd index
158
- // 0 if 'a' contains an 'unknown' value, non-'unknown' values differ, or 'a' has no elements
159
- function homogenousArray ( a , i ) {
160
- var aLen = a [ i ] ? a [ i ] . length : 0 ;
161
- var j = 0 ;
162
-
163
- if ( aLen > 0 ) {
164
- var a0 = a [ i ] [ 0 ] ;
165
- if ( a0 !== 'unknown' && a0 !== '' ) {
166
- for ( j = 1 ; j < aLen ; j ++ ) {
167
- if ( a [ i ] [ j ] === 'unknown' || a [ i ] [ j ] !== a0 ) {
168
- break ;
169
- }
170
- }
171
- }
172
- return j === aLen ? aLen : 0 ;
173
- }
174
- return 0 ;
175
- }
176
-
177
160
var Experiment = module . exports . Experiment = React . createClass ( {
178
161
mixins : [ PickerActionsMixin ] ,
179
162
render : function ( ) {
180
163
var result = this . props . context ;
181
164
var columns = this . props . columns ;
182
- var age = '' ;
183
- var ageUnits = '' ;
184
165
185
166
// See if all life stage, age, and age_unit arrays are all homogeneous
186
- var name = homogenousArray ( result , 'replicates.library.biosample.organism.scientific_name' ) ?
187
- result [ 'replicates.library.biosample.organism.scientific_name' ] [ 0 ] : '' ;
188
- var lifeStage = homogenousArray ( result , 'replicates.library.biosample.life_stage' ) ?
189
- result [ 'replicates.library.biosample.life_stage' ] [ 0 ] : '' ;
190
- var ageLen = homogenousArray ( result , 'replicates.library.biosample.age' ) ;
191
- var ageUnitsLen = homogenousArray ( result , 'replicates.library.biosample.age_units' ) ;
192
- if ( ageLen === ageUnitsLen ) {
193
- age = ageLen ? ' ' + result [ 'replicates.library.biosample.age' ] [ 0 ] : '' ;
194
- ageUnits = ageUnitsLen ? ' ' + result [ 'replicates.library.biosample.age_units' ] [ 0 ] : '' ;
195
- }
167
+ var name , lifeStage , age , ageUnits , homogenous ;
168
+
169
+ // See if all scientific names are the same
170
+ homogenous = result . replicates . every ( function ( replicate ) {
171
+ if ( replicate . library && replicate . library . biosample && replicate . library . biosample . organism &&
172
+ replicate . library . biosample . organism . scientific_name ) {
173
+ if ( name ) {
174
+ return name === replicate . library . biosample . organism . scientific_name ;
175
+ } else {
176
+ // First time, so just seed the name. End if the name exists but is empty
177
+ name = replicate . library . biosample . organism . scientific_name ;
178
+ return name !== '' && name != 'unknown' ;
179
+ }
180
+ } else {
181
+ // replicate doesn't have data, so we're done.
182
+ return false ;
183
+ }
184
+ } ) ;
185
+ name = homogenous ? name : '' ;
186
+
187
+ // See if all life stages are the same
188
+ homogenous = result . replicates . every ( function ( replicate ) {
189
+ if ( replicate . library && replicate . library . biosample && replicate . library . biosample . life_stage ) {
190
+ if ( lifeStage ) {
191
+ return lifeStage === replicate . library . biosample . life_stage ;
192
+ } else {
193
+ // First time, so just seed the name. End if the name exists but is empty
194
+ lifeStage = replicate . library . biosample . life_stage ;
195
+ return lifeStage !== '' && lifeStage != 'unknown' ;
196
+ }
197
+ } else {
198
+ // replicate doesn't have data, so we're done.
199
+ return false ;
200
+ }
201
+ } ) ;
202
+ lifeStage = homogenous ? lifeStage : '' ;
203
+
204
+ // See if all ages are the same
205
+ homogenous = result . replicates . every ( function ( replicate ) {
206
+ if ( replicate . library && replicate . library . biosample && replicate . library . biosample . age ) {
207
+ if ( age ) {
208
+ return age === replicate . library . biosample . age ;
209
+ } else {
210
+ // First time, so just seed the name. End if the name exists but is empty
211
+ age = replicate . library . biosample . age ;
212
+ return age !== '' && age != 'unknown' ;
213
+ }
214
+ } else {
215
+ // replicate doesn't have data, so we're done.
216
+ return false ;
217
+ }
218
+ } ) ;
219
+ age = homogenous ? ' ' + age : '' ;
220
+
221
+ // See if all age units are the same
222
+ homogenous = result . replicates . every ( function ( replicate ) {
223
+ if ( replicate . library && replicate . library . biosample && replicate . library . biosample . age_units ) {
224
+ if ( ageUnits ) {
225
+ return ageUnits === replicate . library . biosample . age_units ;
226
+ } else {
227
+ // First time, so just seed the name. End if the name exists but is empty
228
+ ageUnits = replicate . library . biosample . age_units ;
229
+ return ageUnits !== '' ;
230
+ }
231
+ } else {
232
+ // replicate doesn't have data, so we're done.
233
+ return false ;
234
+ }
235
+ } ) ;
236
+ ageUnits = homogenous ? ' ' + ageUnits : '' ;
237
+
196
238
var separator = ( lifeStage || age ) ? ', ' : '' ;
197
239
240
+ // Get the first treatment
241
+ var treatment = ( result . replicates [ 0 ] && result . replicates [ 0 ] . library && result . replicates [ 0 ] . library . biosample &&
242
+ result . replicates [ 0 ] . library . biosample . treatments [ 0 ] ) ? result . replicates [ 0 ] . library . biosample . treatments [ 0 ] . treatment_term_name : '' ;
243
+
198
244
return ( < li >
199
245
< div >
200
246
{ this . renderActions ( ) }
@@ -223,10 +269,10 @@ var Dbxref = dbxref.Dbxref;
223
269
{ result [ 'target.label' ] }
224
270
</ div >
225
271
: null }
226
- { result [ 'replicates.library.biosample.treatments.treatment_term_name' ] ?
272
+ { treatment ?
227
273
< div >
228
274
< strong > { columns [ 'replicates.library.biosample.treatments.treatment_term_name' ] [ 'title' ] + ': ' } </ strong >
229
- { result [ 'replicates.library.biosample.treatments.treatment_term_name' ] }
275
+ { treatment }
230
276
</ div >
231
277
: null }
232
278
< div > < strong > { columns [ 'lab.title' ] [ 'title' ] } </ strong > : { result [ 'lab.title' ] } </ div >
0 commit comments