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

Add the reference published year as a string to meta to preserve any suffixes #1088

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5877,6 +5877,7 @@
"pageStart": 1303,
"title": "Structures of human Nav1.7 channel in complex with auxiliary subunits and animal toxins",
"meta": {
"yearPublished": "2019a",
"publicationType": "journal"
}
},
Expand Down Expand Up @@ -5948,6 +5949,7 @@
},
"title": "Structures of human Nav1.7 channel in complex with auxiliary subunits and animal toxins",
"meta": {
"yearPublished": "2019b",
"publicationType": "journal"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2179,6 +2179,7 @@
"pageStart": 5950,
"title": "Gustatory Learning and Processing in the Drosophila Mushroom Bodies",
"meta": {
"yearPublished": "2015a",
"publicationType": "journal"
}
},
Expand Down Expand Up @@ -2229,6 +2230,7 @@
"pageStart": 5950,
"title": "Gustatory Learning and Processing in the Drosophila Mushroom Bodies",
"meta": {
"yearPublished": "2015b",
"publicationType": "journal"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3454,6 +3454,7 @@
"title": "Mplus User’s Guide. Eight Edition",
"url": "https://www.statmodel.com",
"meta": {
"yearPublished": "1998-2018",
"publicationType": "book"
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-46472-v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,7 @@ references:
Morphine intake and the effects of naltrexone and buprenorphine on the
acquisition of methamphetamine intake
meta:
yearPublished: 2014a
publicationType: journal
- type: Article
id: bib20
Expand Down Expand Up @@ -1630,6 +1631,7 @@ references:
Opioid sensitivity in mice selectively bred to consume or not consume
methamphetamine
meta:
yearPublished: 2014b
publicationType: journal
- type: Article
id: bib21
Expand Down Expand Up @@ -1698,6 +1700,7 @@ references:
Postsynaptic D2 dopamine receptor supersensitivity in the striatum of mice
lacking TAAR1
meta:
yearPublished: 2015a
publicationType: journal
- type: Article
id: bib22
Expand Down Expand Up @@ -1814,6 +1817,7 @@ references:
pageStart: 2217
title: TAAR1 modulates cortical glutamate NMDA receptor function
meta:
yearPublished: 2015b
publicationType: journal
- type: Article
id: bib23
Expand Down Expand Up @@ -3936,6 +3940,7 @@ references:
A genetic animal model of differential sensitivity to methamphetamine
reinforcement
meta:
yearPublished: 2012a
publicationType: journal
- type: Article
id: bib59
Expand Down Expand Up @@ -3984,6 +3989,7 @@ references:
Profound reduction in sensitivity to the aversive effects of
methamphetamine in mice bred for high methamphetamine intake
meta:
yearPublished: 2012b
publicationType: journal
- type: Article
id: bib60
Expand Down
8 changes: 8 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-46793-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@ references:
Bortezomib as the first proteasome inhibitor anticancer drug: current
status and future perspectives
meta:
yearPublished: 2011a
publicationType: journal
- type: Article
id: bib26
Expand Down Expand Up @@ -1926,6 +1927,7 @@ references:
Selective and cell-active inhibitors of the USP1/ UAF1 deubiquitinase
complex reverse cisplatin resistance in non-small cell lung cancer cells
meta:
yearPublished: 2011b
publicationType: journal
- type: Article
id: bib27
Expand Down Expand Up @@ -2451,6 +2453,7 @@ references:
Reevaluation of telomerase inhibition by quadruplex ligands and their
mechanisms of action
meta:
yearPublished: 2007a
publicationType: journal
- type: Article
id: bib35
Expand Down Expand Up @@ -2503,6 +2506,7 @@ references:
pageStart: 1856
title: Highly efficient G-quadruplex recognition by bisquinolinium compounds
meta:
yearPublished: 2007b
publicationType: journal
- type: Article
id: bib36
Expand Down Expand Up @@ -4058,6 +4062,7 @@ references:
Systematic and integrative analysis of large gene lists using DAVID
bioinformatics resources
meta:
yearPublished: 2009a
publicationType: journal
- type: Article
id: bib60
Expand Down Expand Up @@ -4101,6 +4106,7 @@ references:
Bioinformatics enrichment tools: paths toward the comprehensive functional
analysis of large gene lists
meta:
yearPublished: 2009b
publicationType: journal
- type: Article
id: bib61
Expand Down Expand Up @@ -4836,6 +4842,7 @@ references:
pageStart: 50
title: Targeting the ubiquitin pathway for cancer treatment
meta:
yearPublished: 2015a
publicationType: journal
- type: Article
id: bib75
Expand Down Expand Up @@ -4880,6 +4887,7 @@ references:
associations between human diseases, genes, drugs, metabolites, toxins and
more
meta:
yearPublished: 2015b
publicationType: journal
- type: Article
id: bib76
Expand Down
2 changes: 2 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-52882-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ references:
title: Programs closed-loop phototaxis
url: https://gitlab.com/Phiasso/programs_closed-loop_phototaxis.git
meta:
yearPublished: 2019a
publicationType: software
- type: Article
id: bib30
Expand All @@ -1562,6 +1563,7 @@ references:
title: Analysis behavioral phototaxis
url: https://gitlab.com/Phiasso/analysis.git
meta:
yearPublished: 2019b
publicationType: software
- type: Article
id: bib31
Expand Down
13 changes: 11 additions & 2 deletions src/codecs/jats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,16 @@ export function decodeReference(
]
if (identifiers.length === 0) identifiers = undefined

const meta = typeof label === 'string' ? { label } : undefined
const metaEntries: Record<string, string> = {}
if (
datePublishedString !== undefined &&
(datePublishedString.length > 4 || datePublished === undefined)
) {
metaEntries.yearPublished = datePublishedString
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is that we just store string in meta.yearPublished if it is defined.

if (datePublishedString !== undefined) {
  metaEntries.yearPublished = datePublishedString
}

This will simplify the logic in client too. The only thing tricky in client is to have a fallback id meta.yearPublished is not defined to use datePublished until we do a full reimport.

}
if (typeof label === 'string') {
metaEntries.label = label
}

return stencila.article({
id,
Expand All @@ -1507,7 +1516,7 @@ export function decodeReference(
identifiers,
url,
meta: {
...meta,
...(metaEntries ? { ...metaEntries } : {}),
...(publicationType
? {
publicationType,
Expand Down
24 changes: 24 additions & 0 deletions src/codecs/jats/jats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,30 @@ test.each([
expect(decodeReference(citation, null, undefined)).toEqual(expected)
})

test('decode: reference datePublished is added to meta.yearPublished to preserve suffixes', () => {
const reference = `
<mixed-citation publication-type="journal">
<string-name><surname>Calabrese</surname> <given-names>C</given-names></string-name>, <string-name><surname>Panuzzo</surname> <given-names>C</given-names></string-name> <etal>et al</etal> (<year>2020a</year>) <article-title>Deferasirox-Dependent Iron Chelation Enhances Mitochondrial Dysfunction and Restores p53 Signaling by Stabilization of p53 Family Members in Leukemic Cells</article-title>. <source>International journal of molecular sciences</source> <fpage>21</fpage>
</mixed-citation>
`
const citation = xml.load(reference).elements?.[0]!

const result = decodeReference(citation, null, undefined);
expect(result.meta?.yearPublished).toEqual('2020a');
});

test('decode: reference n.d. is parsed out of date published', () => {
const reference = `
<mixed-citation publication-type="journal">
<string-name><surname>Calabrese</surname> <given-names>C</given-names></string-name>, <string-name><surname>Panuzzo</surname> <given-names>C</given-names></string-name> <etal>et al</etal> (<year>n.d.</year>) <article-title>Deferasirox-Dependent Iron Chelation Enhances Mitochondrial Dysfunction and Restores p53 Signaling by Stabilization of p53 Family Members in Leukemic Cells</article-title>. <source>International journal of molecular sciences</source> <fpage>21</fpage>
</mixed-citation>
`
const citation = xml.load(reference).elements?.[0]!

const result = decodeReference(citation, null, undefined);
expect(result.meta?.yearPublished).toEqual('n.d.');
});

test('decode: <table-wrap> element that has more than one <graphic>', () => {
const fig = xml.load(`
<table-wrap id="tblS1" orientation="portrait" position="float">
Expand Down
Loading