Skip to content

Commit

Permalink
Add support for subjectDisciplines (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisgo authored Aug 22, 2023
1 parent e2c13e4 commit b7f708a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/docmap-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down
7 changes: 7 additions & 0 deletions src/docmap-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ describe('docmap-parser', () => {
doi: '10.1101/123456',
volume: '1',
eLocationId: 'RP123456',
subjects: [
'Biochemistry and Chemical Biology',
'Neuroscience',
],
});
});

Expand Down Expand Up @@ -431,6 +435,9 @@ describe('docmap-parser', () => {
doi: '10.1101/123456',
volume: '1',
eLocationId: 'RP123456',
subjects: [
'subject 1',
],
});
});
});
8 changes: 8 additions & 0 deletions src/docmap-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export type Manuscript = {
doi?: string,
volume?: string,
eLocationId?: string,
subjects?: string[],
};

export type ManuscriptData = {
Expand All @@ -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,
};
};

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/docmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export type Manuscript = {
identifier?: string,
volumeIdentifier?: string,
electronicArticleIdentifier?: string,
subjectDisciplines?: string[],
};

export type Step = {
Expand Down
4 changes: 2 additions & 2 deletions src/test-fixtures/docmapGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit b7f708a

Please sign in to comment.