|
| 1 | +# LinkML Schema Linting and Validation |
| 2 | + |
| 3 | +This project uses [LinkML](https://linkml.io/) to define schemas and validate tabular data files. Below are the commands used to lint and validate schemas and data using `linkml-lint` and `linkml-validate`. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 🔍 Schema Linting |
| 8 | + |
| 9 | +We use `linkml-lint` to check for syntax and structure issues in the schema. |
| 10 | + |
| 11 | +### 1. Full Linting Check |
| 12 | + |
| 13 | +```bash |
| 14 | +linkml-lint src/linkml/include_schema.yaml |
| 15 | +``` |
| 16 | +- **More Info**: [linkml-lint CLI](https://linkml.io/linkml/cli/lint.html) |
| 17 | + |
| 18 | +✅ Data Validation |
| 19 | +----------------- |
| 20 | + |
| 21 | +We use `linkml-validate` to check whether data files conform to their schema definitions. |
| 22 | + |
| 23 | +### 1. Validate `study.csv` against `Study` class |
| 24 | +```bash |
| 25 | +linkml-validate -s src/linkml/include_schema.yaml -C Study src/data/input/study.csv |
| 26 | +``` |
| 27 | +### 2. Validate `participant.csv` against `Participant` class |
| 28 | +```bash |
| 29 | +linkml-validate -s src/linkml/include_schema.yaml -C Participant src/data/input/participant.csv |
| 30 | +``` |
| 31 | +### 3. Validate `condition.csv` against `Condition` class |
| 32 | +```bash |
| 33 | +linkml-validate -s src/linkml/include_schema.yaml -C Condition src/data/input/condition.csv |
| 34 | +``` |
| 35 | +### 4. Validate `biospecimen.csv` against `Biospecimen` class |
| 36 | +```bash |
| 37 | +linkml-validate -s src/linkml/include_schema.yaml -C Biospecimen src/data/input/biospecimen.csv |
| 38 | +``` |
| 39 | +### 5. Validate `datafile.csv` against `DataFile` class |
| 40 | +```bash |
| 41 | +linkml-validate -s src/linkml/include_schema.yaml -C DataFile src/data/input/datafile.csv |
| 42 | +``` |
| 43 | + |
| 44 | +- **More Info**: [linkml-validate CLI](https://linkml.io/linkml/cli/validate.html) |
| 45 | + |
| 46 | +### 📤 Saving Validation Logs |
| 47 | + |
| 48 | +To save validation output to a file (e.g., for documentation or reporting), redirect the output of `linkml-validate`: |
| 49 | + |
| 50 | +```bash |
| 51 | +linkml-validate -s src/linkml/include_schema.yaml -C Study src/data/input/study.csv > src/data/output/validation-report.md |
| 52 | +``` |
| 53 | +You can change the extension to .csv, .txt, or .json based on your preferred format. |
| 54 | + |
| 55 | +📌 Notes |
| 56 | + |
| 57 | +- Ensure all required fields are present in your CSV files. |
| 58 | + |
| 59 | +- Column names in SCV files must match the schema slot names. |
| 60 | + |
| 61 | +- The schema file (src/linkml/include_schema.yaml) must define all referenced classes (Study, Participant, etc.). |
0 commit comments