Skip to content

Commit

Permalink
Merge pull request #7 from C-Accel-CRIPT/feat/typescript
Browse files Browse the repository at this point in the history
feat(scripts): add typescript folder
  • Loading branch information
bearmit authored Apr 12, 2023
2 parents 8e0f6cb + b9eb0e7 commit 7b165d2
Show file tree
Hide file tree
Showing 34 changed files with 1,383 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
out
5 changes: 5 additions & 0 deletions scripts/typescript/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"useTabs": false,
"printWidth": 120
}
13 changes: 13 additions & 0 deletions scripts/typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# AFRL transformation script

The purpose of this node script is to convert AFRL dataset to a CRIPT compatible JSON.
Related to: https://trello.com/c/4eTnhJrp/29-transform-the-afrl-dataset

# `npm i`

Will install this npm package and dependencies.

# Scripts

- `afrl`: see [readme](./src/afrl/README.md)
- `rcbc`: see [readme](./src/rcbc/README.md)
381 changes: 381 additions & 0 deletions scripts/typescript/package-lock.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions scripts/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "cript-typescript",
"version": "1.0.0",
"description": "Set of typescript code to convert raw data (*.csv, *.ts) to CRIPT *.json format",
"main": "index.js",
"scripts": {
"afrl": "npx ts-node src/afrl/index.ts",
"rcbc": "npx ts-node src/rcbc/index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Bérenger Dalle-Cort, CRIPT, MIT",
"license": "MIT",
"dependencies": {
"csvtojson": "^2.0.10",
"ts-node": "^10.9.1",
"typescript": "^5.0.3"
}
}
12 changes: 12 additions & 0 deletions scripts/typescript/src/types/cript/IAlgorithm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IParameter, ICitation } from '.';

/**
* "Algorithm consists of parameter and condition details used in the computation and computational_process. (...)""
* @see https://chemrxiv.org/engage/api-gateway/chemrxiv/assets/orp/resource/item/6322994103e27d9176d5b10c/original/main-supporting-information.pdf#page=24
*/
export type IAlgorithm = {
key: string;
type: string;
parameter: Array<IParameter>;
citation: Array<ICitation>;
};
22 changes: 22 additions & 0 deletions scripts/typescript/src/types/cript/ICitation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { IReference } from "./IReference";

export type CitationType =
'extracted_by_human' |
'extracted_by_nlp' |
'extracted_by_algorithm' |
'derived_from' |
'replicated' |
'reference';

export interface ICitation {
readonly node: ['Citation'];

name: string;
created_at: string;
updated_at: string;
model_version: string;
reference: IReference;
uuid: string;
// type: string;
type: CitationType;
}
20 changes: 20 additions & 0 deletions scripts/typescript/src/types/cript/ICollection..ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { IExperiment, IInventory, IProject } from '.';

export interface ICollection {
locked?: boolean;
model_version?: string;
name: string;
notes?: string;
readonly node: ['Collection'];
public?: boolean;
uid?: string;
uuid?: string;
experiment?: IExperiment[];
experiment_count?: number;
inventory?: IInventory[];
project?: IProject[];
inventory_count?: number;
created_at?: string;
updated_at?: string;
doi?: string;
}
26 changes: 26 additions & 0 deletions scripts/typescript/src/types/cript/IComputation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ICondition, IReference, IData, ISoftwareConfiguration, IExperiment, IIngredient, IProperty } from '.';

/**
* "The computation node describes the transformation of data or the creation of a computational data set (...)"
* @see https://chemrxiv.org/engage/api-gateway/chemrxiv/assets/orp/resource/item/6322994103e27d9176d5b10c/original/main-supporting-information.pdf#page=11
*/
export interface IComputation {
readonly node: ['Computation'];
uid: string;
uuid: string;
citation?: IReference[];
condition?: ICondition[];
model_version: string;
created_at: string;
updated_at: string;
input_data?: IData[];
output_data?: IData[];
locked: boolean;
public: boolean;
name: string;
notes: string;
prerequisite_computation?: IComputation;
software_configuration?: ISoftwareConfiguration[];
type: string;
experiment?: IExperiment[];
}
27 changes: 27 additions & 0 deletions scripts/typescript/src/types/cript/IComputationProcess.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ICondition, IData, IReference, ISoftwareConfiguration, ICitation, IExperiment, IIngredient, IProperty } from '.';

/**
* A computational_process is a simulation that processes or changes a virtual material.
* @see https://chemrxiv.org/engage/api-gateway/chemrxiv/assets/orp/resource/item/6322994103e27d9176d5b10c/original/main-supporting-information.pdf#page=13
*/
export interface IComputationProcess {
readonly node: ['ComputationProcess'];
uid: string;
uuid: string;
type: string;
citation?: ICitation[];
condition?: ICondition[];
model_version: string;
created_at: string;
updated_at: string;
input_data?: IData[];
output_data?: IData[];
locked: boolean;
public: boolean;
name: string;
notes: string;
software_configuration?: ISoftwareConfiguration[];
experiment?: IExperiment[];
ingredient?: IIngredient[];
property?: IProperty[];
}
19 changes: 19 additions & 0 deletions scripts/typescript/src/types/cript/ICondition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IData } from '.';

export interface ICondition {
readonly node: ['Condition'];
data?: IData[];
created_at?: string;
updated_at?: string;
descriptor?: string;
key: string;
measurement_id?: number;
model_version?: string;
set_id?: number;
type?: string;
uncertainty?: string;
uncertainty_type?: string;
unit?: string;
uuid?: string;
value: string;
}
29 changes: 29 additions & 0 deletions scripts/typescript/src/types/cript/IData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { IComputation, IExperiment, IFile, IMaterial, IProcess } from '.';

export interface IData {
readonly node: ['Data'];
name: string;
notes?: string;
type?: string;
uid?: string;
uuid?: string;
file?: IFile[];
file_count?: number;
experiment?: IExperiment[];
citation?: []; // ICitation or ReferencePost
citation_count?: number;
computation_process?: []; //IComputationProcess
computation_process_count?: number;
process?: IProcess[];
process_count?: number;
computation?: IComputation[];
computation_count?: number;
created_at?: string;
updated_at?: string;
locked?: boolean;
public?: boolean;
material?: IMaterial[];
material_count?: number;
model_version?: string;
sample_preparation?: string;
}
23 changes: 23 additions & 0 deletions scripts/typescript/src/types/cript/IEquipment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ICitation } from "./ICitation"
import { ICondition } from "./ICondition";
import { IFile } from "./IFile";

/**
* "Equipment are physical instruments, tools, glassware, etc. used in a process (...)"
* @see https://chemrxiv.org/engage/api-gateway/chemrxiv/assets/orp/resource/item/6322994103e27d9176d5b10c/original/main-supporting-information.pdf#page=21
*
* Typing is from from API's schema
*/
export interface IEquipment {
key: string | undefined; // Not returned bu API yet. (@see https://trello.com/c/ZAR47EVX/10-equipment-schema-key-property-is-missing)
citation?: ICitation[];
condition?: ICondition[];
created_at: string;
description: string;
file?: IFile[];
model_version: string;
node: ['Equipment'];
uid: string;
updated_at: string;
uuid: string;
}
25 changes: 25 additions & 0 deletions scripts/typescript/src/types/cript/IExperiment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ICollection, IComputation, IComputationProcess, IData, IMaterial, IProcess } from '.';

export interface IExperiment {
computation_count?: number;
computation?: IComputation[];
computation_process_count?: number;
computation_process?: IComputationProcess[];
created_at?: string;
data?: IData[];
data_count?: number;
locked?: boolean;
material?: IMaterial[]; // this field is not implemented on the new API, but was present in the legacy API and is used in this project.
material_count?: number; // TODO: remove auestion mark once new API adds the field.
model_version?: string;
name?: string;
notes?: string;
process?: IProcess[];
process_count?: number;
public?: boolean;
uid?: string;
updated_at?: string;
uuid?: string;
collection?: ICollection[];
readonly node: ['Experiment'];
}
8 changes: 8 additions & 0 deletions scripts/typescript/src/types/cript/IFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface IFile {
name: string;
notes: string;
type: string;
uid: string;
uuid: string;
readonly node: ['File'];
}
11 changes: 11 additions & 0 deletions scripts/typescript/src/types/cript/IIdentifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

/**
* @deprecated because identifiers are regular properties on IMaterial node.
*
* The data model describe it differently: "Identifiers are a sub-object for the material node and are unique labels or descriptive information for a material (...)"
* https://chemrxiv.org/engage/api-gateway/chemrxiv/assets/orp/resource/item/6322994103e27d9176d5b10c/original/main-supporting-information.pdf#page=16
*/
export interface IIdentifier {
key: string;
value: string | number | string[] | number[];
}
83 changes: 83 additions & 0 deletions scripts/typescript/src/types/cript/IIngredient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { IMaterial, IQuantity } from ".";

/**
* "Ingredients are links to material nodes with the associated quantities. (...)"
* Data model says @see https://chemrxiv.org/engage/api-gateway/chemrxiv/assets/orp/resource/item/6322994103e27d9176d5b10c/original/main-supporting-information.pdf#page=21
* backend reference:
* "IngredientPost": {
"$id": "IngredientPost",
"additionalProperties": false,
"properties": {
"created_at": {
"default": "now()",
"format": "date-time",
"readOnly": true,
"type": "string"
},
"keyword": {
"enum": [
"monomer",
"polymer",
"initiator",
"catalyst",
"solvent",
"cta",
"quench",
"reagent",
"workup",
"intermediate",
"computation",
"filler",
"matrix",
"inert_carrier_gas"
],
"item": {
"type": "string"
},
"type": "array"
},
"material": {
"$ref": "MaterialPost"
},
"model_version": {
"$ref": "ModelVersion"
},
"node": {
"const": "Ingredient",
"type": "string"
},
"quantity": {
"item": {
"$ref": "QuantityPost"
},
"type": "array"
},
"updated_at": {
"default": "now()",
"format": "date-time",
"readOnly": true,
"type": "string"
},
"uuid": {
"default": "uuid()",
"readOnly": true,
"type": "string"
}
},
"required": [
"node",
"material"
],
"type": "object"
}
*/
export interface IIngredient {
material?: IMaterial[];
quantity?: IQuantity[];
created_at?: string;
keyword?: string[];
model_version?: string;
node: ['Ingredient'];
updated_at?: string;
uuid?: string;
}
13 changes: 13 additions & 0 deletions scripts/typescript/src/types/cript/IInventory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ICollection, IMaterial } from '.';

export interface IInventory {
name: string;
notes?: string;
material_count?: number;
material?: IMaterial[];
public?: boolean;
uid?: string;
uuid?: string;
collection?: ICollection[];
readonly node: ['Inventory'];
}
Loading

0 comments on commit 7b165d2

Please sign in to comment.