Skip to content

Commit

Permalink
Distinguish complex, namedComplex and other with specific BioPAX temp…
Browse files Browse the repository at this point in the history
…late attributes.
  • Loading branch information
jvwong committed Jun 27, 2023
1 parent e7a3694 commit e8d7e9b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/model/element/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,27 @@ class Entity extends Element {
let name = this.name() || '';
let xref = this.getBiopaxXref( omitDbXref );
let orgId = _.get( this.association(), ['organism'] );
let memberXrefs = _.get( this.association(), ['memberXrefs'], null );
let organism = null;

if ( orgId ) {
organism = { id: orgId, db: 'taxonomy' };
}

let entity = { type, name, xref, organism, memberXrefs };
let entity = { type, name, xref, organism };

if ( type == ENTITY_TYPE.COMPLEX ) {
// `complex` shall be defined by components
entity.components = this.participants().map( p => p.toBiopaxTemplate( omitDbXref ) );

} else if ( type == ENTITY_TYPE.NAMED_COMPLEX ) {
// `namedComplex` shall be defined directly, e.g. UnificationXref
let componentXrefs = _.get( this.association(), ['componentXrefs'], null );
if(componentXrefs) entity.componentXrefs = componentXrefs;

} else {
// restricted to subclasses of physical entity
let memberXrefs = _.get( this.association(), ['memberXrefs'], null );
if(memberXrefs) entity.memberXrefs = memberXrefs;
}

return entity;
Expand Down

0 comments on commit e8d7e9b

Please sign in to comment.