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

Gather more values from reference elements if publication-type=other #1086

Merged
merged 10 commits into from
Oct 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,10 @@
"type": "Date",
"value": "2015"
},
"isPartOf": {
"type": "Periodical",
"name": "Nature"
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fred-atherden I am happy with this adjustment with the logic. It would be great for you to scan over all/some of the changes to the fixture in the file_snapshots folder as they represent the alteration to the output of the conversion because of the adjustments we have made to the logic.

I have removed the addition of meta.type to the decoded reference so we can reduce the differences in this review. As soon as this is merged in I will prepare that PR as a followup.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for this @nlisgo, I've taken a look at the changes to the file snapshots and they're looking good. We're surfacing more information as desired. I think we're good to go ahead with this - thanks for your help!

"title": "Non-adaptive plasticity potentiates rapid adaptive evolution of gene expression in nature"
},
{
Expand Down Expand Up @@ -2552,6 +2556,10 @@
"type": "Date",
"value": "2021"
},
"isPartOf": {
"type": "Periodical",
"name": "R package version 1.7.1-1"
},
"title": "emmeans: Estimated Marginal Means, aka Least-Squares Means"
},
{
Expand Down Expand Up @@ -2714,6 +2722,10 @@
"value": "XXXX"
}
],
"isPartOf": {
"type": "Periodical",
"name": "bioRxiv"
},
"title": "Variation in mutational (co)variances"
},
{
Expand Down Expand Up @@ -2780,6 +2792,10 @@
"type": "Date",
"value": "2019"
},
"isPartOf": {
"type": "Periodical",
"name": "bioRxiv"
},
"pageStart": 778282,
"title": "Phenotypic stasis with genetic divergence"
},
Expand Down Expand Up @@ -3731,6 +3747,10 @@
"value": "10.1101/506865"
}
],
"isPartOf": {
"type": "Periodical",
"name": "Ecology Letters, page"
},
"title": "How differing modes of non-genetic inheritance affect population viability in fluctuating environments"
},
{
Expand Down Expand Up @@ -4114,6 +4134,10 @@
"type": "Date",
"value": "2018"
},
"isPartOf": {
"type": "Periodical",
"name": "R package version 2.18.2"
},
"title": "RStan: the R interface to Stan"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
"type": "Date",
"value": "2022"
},
"isPartOf": {
"type": "Periodical",
"name": "Circular Statistics (version 0.4-94)"
},
"title": "R package “circular”"
},
{
Expand Down Expand Up @@ -1934,6 +1938,10 @@
"value": "10.1093/jxb/51.349.1403"
}
],
"isPartOf": {
"type": "Periodical",
"name": "J Exp Bot"
},
"title": "Hormonal influence on photocontrol of the protandry in the genus Helianthus"
},
{
Expand Down Expand Up @@ -2851,7 +2859,7 @@
"value": "10.3120/0024-9637-56.3.209"
}
],
"title": "Patterson B. 2009. Systematics, Evolution, and Biogeography of Compositae, Madroño. doi:10.3120/0024-9637-56.3.209"
"title": "Systematics, Evolution, and Biogeography of Compositae, Madroño"
},
{
"type": "Article",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,10 @@
"type": "Date",
"value": "1988"
},
"isPartOf": {
"type": "PublicationVolume",
"volumeNumber": 8
},
"title": "T-cell antigen receptor genes and T-cell recognition",
"meta": {
"label": "9."
Expand Down Expand Up @@ -5685,11 +5689,7 @@
"value": "10.1146/annurev-immunol-102819-023144"
}
],
"isPartOf": {
"type": "Periodical",
"name": "Annu. Rev. Immunol."
},
"title": "A. C. Hayday, P. Vantourout, Annu. Rev. Immunol., in press, doi:10.1146/annurev-immunol-102819-023144.",
"title": "Annu. Rev. Immunol.",
"meta": {
"label": "46."
}
Expand Down Expand Up @@ -6651,6 +6651,10 @@
]
}
],
"isPartOf": {
"type": "PublicationVolume",
"volumeNumber": 8
},
"title": "OLGA: fast computation of generation probabilities of B- and T-cell receptor amino acid sequences and motifs",
"meta": {
"label": "62."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3538,13 +3538,9 @@
},
"isPartOf": {
"type": "PublicationVolume",
"isPartOf": {
"type": "Periodical",
"name": "Internal amino acid state modulates yeast taste neurons to support protein homeostasis in Drosophila"
},
"volumeNumber": 29
},
"title": "Steck K, Walker SJ, Itskov PM, Baltazar C, Moreira J-M, Ribeiro C. 2018. Internal amino acid state modulates yeast taste neurons to support protein homeostasis in Drosophila 29."
"title": "Internal amino acid state modulates yeast taste neurons to support protein homeostasis in Drosophila"
},
{
"type": "Article",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,10 @@
"type": "Date",
"value": "2021"
},
"isPartOf": {
"type": "Periodical",
"name": "MedRxiv"
},
"title": "Obesity and accelerated epigenetic aging in a high-risk cohort of children",
"url": "https://doi.org/10.1101/2021.11.03.21265865"
},
Expand Down Expand Up @@ -3091,6 +3095,10 @@
"type": "Date",
"value": "2021"
},
"isPartOf": {
"type": "Periodical",
"name": "MedRxiv"
},
"title": "BMI is positively associated with accelerated epigenetic aging in twin pairs discordant for BMI",
"url": "https://doi.org/10.1101/2021.03.11.21253271"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@
"type": "Date",
"value": "2010"
},
"title": "Andrews, S., 2010. FastQC: a quality control tool for high throughput sequence data."
"title": "FastQC: a quality control tool for high throughput sequence data"
},
{
"type": "Article",
Expand Down
1 change: 1 addition & 0 deletions src/codecs/jats/__file_snapshots__/elife-30274-v1.jats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,7 @@
<article-title>R: A language and environment for statistical computing</article-title>
<person-group person-group-type="author"/>
<year iso-8601-date="2017">2017</year>
<source>R Foundation for Statistical Computing</source>
</element-citation>
</ref>
<ref id="bib26">
Expand Down
3 changes: 3 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-30274-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,9 @@ references:
datePublished:
type: Date
value: '2017'
isPartOf:
type: Periodical
name: R Foundation for Statistical Computing
title: 'R: A language and environment for statistical computing'
- type: Article
id: bib26
Expand Down
1 change: 1 addition & 0 deletions src/codecs/jats/__file_snapshots__/elife-43154-v2.jats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,7 @@
</name>
</person-group>
<year iso-8601-date="2019">2019</year>
<source>GitHub</source>
</element-citation>
</ref>
<ref id="bib12">
Expand Down
3 changes: 3 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-43154-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,9 @@ references:
datePublished:
type: Date
value: '2019'
isPartOf:
type: Periodical
name: GitHub
title: Severe Malaria
url: https://github.com/Stije/SevereMalariaAnalysis
- type: Article
Expand Down
1 change: 1 addition & 0 deletions src/codecs/jats/__file_snapshots__/elife-46472-v3.jats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4449,6 +4449,7 @@
</name>
</person-group>
<year iso-8601-date="2012">2012</year>
<source>December 12, 2012; Published at US008697359B1 (Awarded)</source>
</element-citation>
</ref>
</ref-list>
Expand Down
3 changes: 3 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-46472-v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4559,6 +4559,9 @@ references:
datePublished:
type: Date
value: '2012'
isPartOf:
type: Periodical
name: December 12, 2012; Published at US008697359B1 (Awarded)
title: Systems methods and compositions for sequence manipulation
url: https://patents.google.com/patent/WO2015089486A3/en
title:
Expand Down
2 changes: 2 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-46793-v1.jats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3942,6 +3942,7 @@
</ref>
<ref id="bib49">
<element-citation>
<article-title> FASTQ/A Short-Reads Pre-Processing Tools</article-title>
<person-group person-group-type="author">
<name>
<surname>Gordon</surname>
Expand Down Expand Up @@ -5121,6 +5122,7 @@
</name>
</person-group>
<year iso-8601-date="2019">2019</year>
<source>GitHub</source>
</element-citation>
</ref>
<ref id="bib80">
Expand Down
4 changes: 4 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-46793-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3236,6 +3236,7 @@ references:
datePublished:
type: Date
value: '2010'
title: "\_FASTQ/A Short-Reads Pre-Processing Tools"
url: http://hannonlab.cshl.edu/fastx_toolkit/download.html
- type: Article
id: bib50
Expand Down Expand Up @@ -4987,6 +4988,9 @@ references:
datePublished:
type: Date
value: '2019'
isPartOf:
type: Periodical
name: GitHub
title: GWscreen_G4sensitivity
url: https://github.com/sblab-bioinformatics/GWscreen_G4sensitivity
- type: Article
Expand Down
2 changes: 2 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-52882-v2.jats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11748,6 +11748,7 @@
</name>
</person-group>
<year iso-8601-date="2019">2019</year>
<source>GitLab</source>
</element-citation>
</ref>
<ref id="bib30">
Expand All @@ -11760,6 +11761,7 @@
</name>
</person-group>
<year iso-8601-date="2019">2019</year>
<source>GitLab</source>
</element-citation>
</ref>
<ref id="bib31">
Expand Down
6 changes: 6 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-52882-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,9 @@ references:
datePublished:
type: Date
value: '2019'
isPartOf:
type: Periodical
name: GitLab
title: Programs closed-loop phototaxis
url: https://gitlab.com/Phiasso/programs_closed-loop_phototaxis.git
- type: Article
Expand All @@ -1495,6 +1498,9 @@ references:
datePublished:
type: Date
value: '2019'
isPartOf:
type: Periodical
name: GitLab
title: Analysis behavioral phototaxis
url: https://gitlab.com/Phiasso/analysis.git
- type: Article
Expand Down
52 changes: 33 additions & 19 deletions src/codecs/jats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1351,42 +1351,56 @@ export function decodeReference(

let title: string | undefined
let isPartOf: stencila.CreativeWork | undefined
if (publicationType === 'journal' || publicationType === 'preprint') {
let chapterTitle: string | undefined

// Assign the title based upon the publicationType
if (['journal', 'preprint'].includes(publicationType ?? '')) {
title = textOrUndefined(child(elem, 'article-title'))
} else if (['book', 'report'].includes(publicationType ?? '')) {
chapterTitle = textOrUndefined(child(elem, 'chapter-title'))
// Not a chapter so title is <source>
title = chapterTitle ?? textOrUndefined(child(elem, 'source'))
} else {
// e.g. publicationType: 'software', 'web', 'patent'
title = textOrUndefined(
child(elem, ['article-title', 'chapter-title', 'data-title']),
)
}

const periodicalName = textOrUndefined(child(elem, 'source'))
const volumeNumber = intOrUndefined(child(elem, 'volume'))
const issueNumber = intOrUndefined(child(elem, 'issue'))
if (periodicalName !== undefined)
isPartOf = stencila.periodical({ name: periodicalName })
if (volumeNumber !== undefined)
isPartOf = stencila.publicationVolume({ volumeNumber, isPartOf })
if (issueNumber !== undefined)
isPartOf = stencila.publicationIssue({ issueNumber, isPartOf })
} else if (publicationType === 'book' || publicationType === 'report') {
title = textOrUndefined(child(elem, 'chapter-title'))
if (title !== undefined) {
// Assign isPartOf based upon the publicationType
if (['book', 'report'].includes(publicationType ?? '')) {
if (chapterTitle !== undefined) {
// Book or report chapter so try to create a `isPartOf` property
const book = textOrUndefined(child(elem, 'source'))
if (book !== undefined) {
isPartOf = stencila.creativeWork({ name: book })
}
}
} else {
// e.g. publicationType: 'journal', 'preprint', 'software', 'web', 'patent', 'other'
if (title !== undefined) {
const periodicalName = textOrUndefined(child(elem, 'source'))
if (periodicalName !== undefined)
isPartOf = stencila.periodical({ name: periodicalName })
} else {
// Not a chapter so title is <source>
title = textOrUndefined(child(elem, 'source'))
fred-atherden marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
// e.g. publicationType: 'software', 'web', 'patent'
title = textOrUndefined(
child(elem, ['article-title', 'chapter-title', 'data-title']),
)
const volumeNumber = intOrUndefined(child(elem, 'volume'))
const issueNumber = intOrUndefined(child(elem, 'issue'))
if (volumeNumber !== undefined)
isPartOf = stencila.publicationVolume({ volumeNumber, isPartOf })
if (issueNumber !== undefined)
isPartOf = stencila.publicationIssue({ issueNumber, isPartOf })
}

// If title is still undefined and elem is a <mixed-citation> then use
// its text content e.g.
// <mixed-citation publication-type="other" xlink:type="simple">Maynard Smith J (1982) Evolution and the Theory of Games. Cambridge University Press.</mixed-citation>
if (title === undefined && elem.name === 'mixed-citation') {
title = textOrUndefined(elem)
// Removing authors and isPartOf to reduce duplication
authors = []
isPartOf = undefined
}

// Remove any space placeholders
Expand Down
Loading
Loading