Skip to content

Commit

Permalink
Improved handling of empty/short affiliations
Browse files Browse the repository at this point in the history
  • Loading branch information
eidens committed Oct 4, 2023
1 parent 9f3ac7d commit d5580b3
Show file tree
Hide file tree
Showing 18 changed files with 762 additions and 58 deletions.
46 changes: 29 additions & 17 deletions mecadoi/crossref/peer_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
DoiBatch,
DoiData,
Head,
Institution,
Institution as CrossrefInstitution,
InterWorkRelation,
Orcid,
PeerReview,
Expand All @@ -37,7 +37,7 @@
ReviewDate,
Titles,
)
from mecadoi.model import Author
from mecadoi.model import Author, Institution as MecadoiInstitution


def generate_peer_review_deposition(articles: List[Article]) -> str:
Expand Down Expand Up @@ -119,7 +119,7 @@ def generate_reviews(article: Article) -> Generator[PeerReview, None, None]:
month=review.publication_date.month,
day=review.publication_date.day,
),
institution=Institution(institution_name=INSTITUTION_NAME),
institution=CrossrefInstitution(institution_name=INSTITUTION_NAME),
running_number=str(running_number),
program=Program(related_item=[is_review_of_relation]),
doi_data=DoiData(
Expand Down Expand Up @@ -149,7 +149,7 @@ def generate_reviews(article: Article) -> Generator[PeerReview, None, None]:
month=review.publication_date.month,
day=review.publication_date.day,
),
institution=Institution(institution_name=INSTITUTION_NAME),
institution=CrossrefInstitution(institution_name=INSTITUTION_NAME),
running_number="Author Reply",
program=Program(
related_item=[is_review_of_relation]
Expand All @@ -171,6 +171,30 @@ def generate_reviews(article: Article) -> Generator[PeerReview, None, None]:
)


def create_institution(institution: MecadoiInstitution) -> CrossrefInstitution:
city = (
institution.city
if institution.city and len(institution.city) > 1
else None
)
country = (
institution.country
if institution.country and len(institution.country) > 1
else None
)
place = (
f"{city}, {country}" if city and country
else city if city
else country if country
else None
)
return CrossrefInstitution(
institution_name=institution.name,
institution_department=institution.department,
institution_place=place,
)


def create_contributors(authors: List[Author]) -> Contributors:
contributors = Contributors(
person_name=[
Expand All @@ -182,19 +206,7 @@ def create_contributors(authors: List[Author]) -> Contributors:
affiliations=(
Affiliations(
institution=[
Institution(
institution_name=institution.name,
institution_department=institution.department,
institution_place=(
f"{institution.city}, {institution.country}"
if institution.city and institution.country
else institution.city
if institution.city
else institution.country
if institution.country
else None
),
)
create_institution(institution)
for institution in author.institutions
]
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# If any command fails, exit immediately with that command's exit status
set -eo pipefail

ENV_FILE=.env.ci python -m unittest
ENV_FILE=.env.ci python -m unittest $@
115 changes: 115 additions & 0 deletions tests/resources/expected/no-institution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<doi_batch xmlns="http://www.crossref.org/schema/5.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5.3.1" xsi:schemaLocation="http://www.crossref.org/schema/5.3.1 http://www.crossref.org/schemas/crossref5.3.1.xsd">
<head>
<doi_batch_id>0000</doi_batch_id>
<timestamp>0</timestamp>
<depositor>
<depositor_name>EMBO</depositor_name>
<email_address>[email protected]</email_address>
</depositor>
<registrant>EMBO</registrant>
</head>
<body>
<peer_review language="en" revision-round="0" stage="pre-publication" type="referee-report">
<contributors>
<anonymous sequence="first" contributor_role="author"></anonymous>
</contributors>
<titles>
<title>Peer Review #1 of An article with a single revision round.</title>
</titles>
<review_date>
<month>10</month>
<day>20</day>
<year>2020</year>
</review_date>
<institution>
<institution_name>Review Commons</institution_name>
</institution>
<running_number>1</running_number>
<rel:program xmlns:rel="http://www.crossref.org/relations.xsd">
<rel:related_item>
<rel:inter_work_relation relationship-type="isReviewOf" identifier-type="doi">10.1101/single-revision-round.123.456.7890</rel:inter_work_relation>
</rel:related_item>
</rel:program>
<doi_data>
<doi>10.15252/rc.2020123456</doi>
<resource>https://eeb.embo.org/doi/10.1101/single-revision-round.123.456.7890#rev0-rr1</resource>
</doi_data>
</peer_review>
<peer_review language="en" revision-round="0" stage="pre-publication" type="referee-report">
<contributors>
<anonymous sequence="first" contributor_role="author"></anonymous>
</contributors>
<titles>
<title>Peer Review #2 of An article with a single revision round.</title>
</titles>
<review_date>
<month>10</month>
<day>20</day>
<year>2020</year>
</review_date>
<institution>
<institution_name>Review Commons</institution_name>
</institution>
<running_number>2</running_number>
<rel:program xmlns:rel="http://www.crossref.org/relations.xsd">
<rel:related_item>
<rel:inter_work_relation relationship-type="isReviewOf" identifier-type="doi">10.1101/single-revision-round.123.456.7890</rel:inter_work_relation>
</rel:related_item>
</rel:program>
<doi_data>
<doi>10.15252/rc.2020123456</doi>
<resource>https://eeb.embo.org/doi/10.1101/single-revision-round.123.456.7890#rev0-rr2</resource>
</doi_data>
</peer_review>
<peer_review language="en" revision-round="0" stage="pre-publication" type="author-comment">
<contributors>
<person_name contributor_role="author" sequence="first">
<given_name>Jane</given_name>
<surname>Doe</surname>
<affiliations>
<institution>
<institution_name>/</institution_name>
</institution>
</affiliations>
<ORCID authenticated="true">https://orcid.org/0000-0012-3456-7890</ORCID>
</person_name>
<person_name contributor_role="author" sequence="additional">
<given_name>John</given_name>
<surname>Doe</surname>
<affiliations>
<institution>
<institution_name>/</institution_name>
</institution>
</affiliations>
</person_name>
</contributors>
<titles>
<title>Author Reply to Peer Reviews of An article with a single revision round.</title>
</titles>
<review_date>
<month>10</month>
<day>20</day>
<year>2020</year>
</review_date>
<institution>
<institution_name>Review Commons</institution_name>
</institution>
<running_number>Author Reply</running_number>
<rel:program xmlns:rel="http://www.crossref.org/relations.xsd">
<rel:related_item>
<rel:inter_work_relation identifier-type="doi" relationship-type="isReviewOf">10.1101/single-revision-round.123.456.7890</rel:inter_work_relation>
</rel:related_item>
<rel:related_item>
<rel:inter_work_relation identifier-type="doi" relationship-type="isReplyTo">10.15252/rc.2020123456</rel:inter_work_relation>
</rel:related_item>
<rel:related_item>
<rel:inter_work_relation identifier-type="doi" relationship-type="isReplyTo">10.15252/rc.2020123456</rel:inter_work_relation>
</rel:related_item>
</rel:program>
<doi_data>
<doi>10.15252/rc.2020123456</doi>
<resource>https://eeb.embo.org/doi/10.1101/single-revision-round.123.456.7890#rev0-ar</resource>
</doi_data>
</peer_review>
</body>
</doi_batch>
34 changes: 34 additions & 0 deletions tests/resources/expected/no-institution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
doi: 10.1101/single-revision-round.123.456.7890
review_process:
- author_reply:
authors:
- affiliation: /
given_name: Jane
is_corresponding_author: true
orcid:
id: https://orcid.org/0000-0012-3456-7890
is_authenticated: true
surname: Doe
- affiliation: /
given_name: John
is_corresponding_author: false
orcid: null
surname: Doe
doi: 10.15252/rc.2020123456
publication_date: 2020-10-20 00:00:00
text: {}
reviews:
- authors: []
doi: 10.15252/rc.2020123456
publication_date: 2020-10-20 00:00:00
text:
Estimated time to Complete Revisions (Required): Cannot tell / Not applicable
Significance (Required): Lorem ipsum dolor sit amet.
- authors: []
doi: 10.15252/rc.2020123456
publication_date: 2020-10-20 00:00:00
text:
Estimated time to Complete Revisions (Required): Between 3 and 6 months
Evidence, reproducibility and clarity (Required): 'Summary: this is a test'
Significance (Required): 'Signification: also a test'
title: An article with a single revision round.
Binary file not shown.
Binary file not shown.
Binary file added tests/resources/meca/no-institution/Article-1.doc
Binary file not shown.
Binary file added tests/resources/meca/no-institution/Article.doc
Binary file not shown.
137 changes: 137 additions & 0 deletions tests/resources/meca/no-institution/article.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article SYSTEM "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.2d1">
<front>
<journal-meta>
<journal-id journal-id-type="publisher">reviewcommonstest</journal-id>
<journal-title-group>
<journal-title>Review Commons - TEST</journal-title>
<abbrev-journal-title abbrev-type="nlm-ta" />
</journal-title-group>
<issn pub-type="ppub">2575-1077</issn>
<issn pub-type="epub">2575-1077</issn>
</journal-meta>
<article-meta>
<article-id pub-id-type="doi">10.12345/single-revision-round.1234567890</article-id>
<article-id pub-id-type="manuscript">single-revision-round-2020-1234</article-id>
<article-categories>
<subj-group subj-group-type="Article Type">
<subject>Research Article</subject>
</subj-group>
</article-categories>
<title-group>
<article-title>An article with a single revision round.</article-title>
</title-group>
<contrib-group>
<contrib contrib-type="author" corresp="yes">
<contrib-id contrib-id-type="orcid" specific-use="authenticated">https://orcid.org/0000-0012-3456-7890</contrib-id>
<name>
<surname>Doe</surname>
<given-names>Jane</given-names>
<prefix>Dr.</prefix>
</name>
<email>[email protected]</email>
<role content-type="1" />
<xref ref-type="aff" rid="aff1" />
</contrib>
<contrib contrib-type="author">
<name>
<surname>Doe</surname>
<given-names>John</given-names>
</name>
<email>[email protected]</email>
<role content-type="2" />
<xref ref-type="aff" rid="aff2" />
</contrib>
<aff id="aff1">
<institution>/</institution>
<addr-line content-type="addrline1">None</addr-line>
<addr-line content-type="city">/</addr-line>
<addr-line content-type="zipcode">/</addr-line>
<country>/</country>
</aff>
<aff id="aff2">
<institution>/</institution>
<addr-line content-type="addrline1">None</addr-line>
<addr-line content-type="city">/</addr-line>
<addr-line content-type="zipcode">/</addr-line>
</aff>
</contrib-group>
<author-notes>
<corresp id="cor1">
<label>*</label>
<bold>Corresponding Author:</bold>
Jane Doe, Medicinal Chemistry, EMBL
</corresp>
<fn fn-type="con">
<p>Author contributions: J.D. conceptualization; J.D. data curation.</p>
</fn>
</author-notes>
<pub-date pub-type="epub" />
<pub-date pub-type="ppub" />
<elocation-id>1234-5678.single-revision-round-2020-1234</elocation-id>
<history>
<date date-type="received">
<day>12</day>
<month>12</month>
<year>2020</year>
</date>
</history>
<permissions>
<copyright-statement></copyright-statement>
<copyright-year>2020</copyright-year>
</permissions>
<abstract abstract-type="primary">
<p>This article has a single revision round and thus in ...</p>
</abstract>
<kwd-group>
<kwd>test</kwd>
<kwd>test1</kwd>
<kwd>test2</kwd>
</kwd-group>
<funding-group>
<award-group>
<funding-source>
EMBO
<named-content content-type="funder-id">http://dx.doi.org/10.12345/asdf1234567890</named-content>
</funding-source>
<principal-award-recipient></principal-award-recipient>
</award-group>
</funding-group>
<custom-meta-group>
<custom-meta>
<meta-name>dual_publication</meta-name>
<meta-value>0</meta-value>
</custom-meta>
<custom-meta>
<meta-name>human_subjects</meta-name>
<meta-value>0</meta-value>
</custom-meta>
<custom-meta>
<meta-name>animal_subjects</meta-name>
<meta-value>0</meta-value>
</custom-meta>
<custom-meta>
<meta-name>Rebuttal Submitted to Hypothes.is</meta-name>
<meta-value>Yes</meta-value>
</custom-meta>
<custom-meta>
<meta-name>Pre-existing BioRxiv Preprint</meta-name>
<meta-value>Yes</meta-value>
</custom-meta>
<custom-meta>
<meta-name>Pre-existing BioRxiv Preprint DOI</meta-name>
<meta-value>10.1101/single-revision-round.123.456.7890</meta-value>
</custom-meta>
<custom-meta>
<meta-name>BioRxiv Preprint Submitted on Author's Behalf</meta-name>
<meta-value>Yes</meta-value>
</custom-meta>
<custom-meta>
<meta-name>Acknowledgment of Policy on Original Data</meta-name>
<meta-value>EJ</meta-value>
</custom-meta>
</custom-meta-group>
</article-meta>
</front>
</article>
Binary file added tests/resources/meca/no-institution/decision.pdf
Binary file not shown.
Loading

0 comments on commit d5580b3

Please sign in to comment.