diff --git a/src/docmap-generator.ts b/src/docmap-generator.ts index a5371ae..875a9e6 100644 --- a/src/docmap-generator.ts +++ b/src/docmap-generator.ts @@ -114,12 +114,13 @@ export const generateWebContent = (url: Url): WebPage => ({ url, }); -export const generateManuscript = (doi?: DOI, identifier?: string, volumeIdentifier?: string, electronicArticleIdentifier?: string): Manuscript => ({ +export const generateManuscript = (doi?: DOI, identifier?: string, volumeIdentifier?: string, electronicArticleIdentifier?: string, subjectDisciplines?: string[]): Manuscript => ({ type: 'manuscript', doi, identifier, volumeIdentifier, electronicArticleIdentifier, + subjectDisciplines, }); export const generatePersonParticipant = (name: string, role: string): Participant => ({ diff --git a/src/docmap-parser.test.ts b/src/docmap-parser.test.ts index 8e12779..f4984d2 100644 --- a/src/docmap-parser.test.ts +++ b/src/docmap-parser.test.ts @@ -393,6 +393,10 @@ describe('docmap-parser', () => { doi: '10.1101/123456', volume: '1', eLocationId: 'RP123456', + subjects: [ + 'Biochemistry and Chemical Biology', + 'Neuroscience', + ], }); }); @@ -431,6 +435,9 @@ describe('docmap-parser', () => { doi: '10.1101/123456', volume: '1', eLocationId: 'RP123456', + subjects: [ + 'subject 1', + ], }); }); }); diff --git a/src/docmap-parser.ts b/src/docmap-parser.ts index 9fdb812..149bb1f 100644 --- a/src/docmap-parser.ts +++ b/src/docmap-parser.ts @@ -84,6 +84,7 @@ export type Manuscript = { doi?: string, volume?: string, eLocationId?: string, + subjects?: string[], }; export type ManuscriptData = { @@ -101,6 +102,7 @@ const getManuscriptFromExpression = (expression: Expression): Manuscript | false doi: expression.partOf.doi, volume: expression.partOf.volumeIdentifier, eLocationId: expression.partOf.electronicArticleIdentifier, + subjects: expression.partOf.subjectDisciplines, }; }; @@ -203,6 +205,9 @@ const findAndUpdateOrAddPreprintDescribedBy = (expression: Expression, preprintC if (foundManuscriptData.volume) { existingManuscript.volume = foundManuscriptData.volume; } + if (foundManuscriptData.subjects) { + existingManuscript.subjects = foundManuscriptData.subjects; + } } const foundPreprint = findPreprintDescribedBy(expression, preprintCollection); if (!foundPreprint) { @@ -230,6 +235,9 @@ const republishPreprintAs = (expression: Expression, preprint: ReviewedPreprint, if (foundManuscriptData.volume) { existingManuscript.volume = foundManuscriptData.volume; } + if (foundManuscriptData.subjects) { + existingManuscript.subjects = foundManuscriptData.subjects; + } } const newPreprint = preprint; diff --git a/src/docmap.ts b/src/docmap.ts index 6b0b81c..ab7a547 100644 --- a/src/docmap.ts +++ b/src/docmap.ts @@ -122,6 +122,7 @@ export type Manuscript = { identifier?: string, volumeIdentifier?: string, electronicArticleIdentifier?: string, + subjectDisciplines?: string[], }; export type Step = { diff --git a/src/test-fixtures/docmapGenerators.ts b/src/test-fixtures/docmapGenerators.ts index c728ef2..5212f0c 100644 --- a/src/test-fixtures/docmapGenerators.ts +++ b/src/test-fixtures/docmapGenerators.ts @@ -49,7 +49,7 @@ export const fixtures = { }, preprintWithManuscriptAsOutput: (): DocMap => { - const manuscript = generateManuscript('10.1101/123456', '123456', '1', 'RP123456'); + const manuscript = generateManuscript('10.1101/123456', '123456', '1', 'RP123456', ['Biochemistry and Chemical Biology', 'Neuroscience']); const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, manuscript); const firstStep = generateStep([], [generateAction([], [preprint])], []); return generateDocMap('test', publisher, firstStep); @@ -64,7 +64,7 @@ export const fixtures = { preprintWithUmbrellaExpressionsFromMultipleLocations: (): DocMap => { const manuscript = generateManuscript('10.1101/123456', '123456', undefined, 'RP123456'); - const manuscript2 = generateManuscript('10.1101/123456', '123456', "1"); + const manuscript2 = generateManuscript('10.1101/123456', '123456', "1", undefined, ['subject 1']); const preprint = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, manuscript); const preprint2 = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, undefined, undefined, undefined, manuscript2); const assertion = generateDraftAssertion(preprint2);