Skip to content

Commit

Permalink
Merge pull request #1234 from PathwayCommons/iss1218_preprint-publica…
Browse files Browse the repository at this point in the history
…tionXref

Generate as complete as possible publication xref from the citation.
  • Loading branch information
jvwong authored Dec 11, 2023
2 parents af2414a + cd099cb commit 748547b
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/model/document/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,38 @@ class Document {
}

toBiopaxTemplate( omitDbXref ){
const toPublication = citation => {
let { pmid, doi, title, reference: source, authors: { authorList }, ISODate } = citation;
let db, id;
if ( pmid ){
db = 'pmid';
id = pmid;
} else if( doi ) {
db = 'crossref';
id = doi;
}
const publication = { db, id, title, source };
if( ISODate ) {
const date = new Date( ISODate );
const year = date.getFullYear();
publication.year = year;
}
if( !_.isEmpty( authorList ) ) {
const author = authorList.map( ({ name }) => name );
publication.author = author;
}
return publication;
};
let interactions = this.toBiopaxIntnTemplates( omitDbXref );
let citation = this.citation();
let pathwayName = citation.title;
let pmid = citation.pmid;
let { pmid, doi, title } = citation;
const hasArticleId = pmid != null || doi != null;
let pathwayId = this.id();

let template = { interactions, pathwayName, pathwayId };
if ( pmid ) {
template.publication = { id: pmid, db: 'pubmed' };
let template = { interactions, pathwayName: title, pathwayId };
if ( hasArticleId ) {
const publication = toPublication( citation );
template.publication = publication;
}

return template;
Expand Down

0 comments on commit 748547b

Please sign in to comment.