Skip to main content

Reproschema Python library

Project description

Python package

Reproschema Python library and Command Line Interface (CLI)

Installation

reproschema requires Python 3.10+.

pip install reproschema

Developer installation

Fork this repo to your own GitHub account, then clone and install your forked repo in the developer mode:

git clone https://github.com/<your github>/reproschema-py.git
cd reproschema-py
pip install -e .

Style

This repo uses pre-commit to check styling.

  • Install pre-commit with pip: pip install pre-commit
  • In order to use it with the repository, you have to run run pre-commit install in the root directory the first time you use it.

When pre-commit is used, you may have to run git commit twice, since pre-commit may make additional changes to your code for styling and will not commit these changes by default.

CLI usage

This package installs reproschema Command Line Interface (CLI).

$ reproschema --help

$  A client to support interactions with ReproSchema

  To see help for a specific command, run

  reproschema COMMAND --help     e.g. reproschema validate --help

Options:
  --version
  -l, --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  Log level name  [default: INFO]
  --help                          Show this message and exit.

Commands:
  convert             Converts a path to a different format, jsonld,...
  create
  migrate             Updates to a new reproschema version
  redcap2reproschema  Converts REDCap CSV files to Reproschema format.
  reproschema2redcap  Converts reproschema protocol to REDCap CSV format.
  serve
  validate            Validates if the path has a valid reproschema format

reproschema2redcap

CLI Usage

You can use this feature directly from the command line. To convert ReproSchema protocol to REDCap CSV format, use the following command

reproschema reproschema2redcap <input_dir_path> <output_csv_filename>
  • <input_dir_path>: The path to the root folder of a protocol. For example, to convert the reproschema-demo-protocol provided by ReproNim, you can use the following commands:
    git clone https://github.com/ReproNim/reproschema-demo-protocol.git
    cd reproschema-demo-protocol
    pwd
    
    In this case, the output from pwd (which shows your current directory path) should be your <input_dir_path>.
  • <output_csv_filename>: The name of the output CSV file where the converted data will be saved.

Python Function Usage

You can also use the reproschema2redcap function from the reproschema-py package in your Python code.

from reproschema import reproschema2redcap

input_dir_path = "path-to/reproschema-demo-protocol"
output_csv_filename = "output.csv"

reproschema2redcap(input_dir_path, output_csv_filename)

redcap2reproschema

The redcap2reproschema function is designed to process a given REDCap CSV file and YAML configuration to generate the output in the reproschema format.

Prerequisites

Before the conversion, ensure you have the following:

YAML Configuration File:

YAML File Configuration

In the templates/redcap2rs.yaml file, provide the following information:

  • protocol_name: A unique identifier for your protocol. Use underscores for spaces and avoid special characters.
  • protocol_display_name: Name that will appear in the application.
  • protocol_description: A brief description of your protocol.
  • redcap_version: Version of your redcap file (you can customize it).

Example:

protocol_name: "My_Protocol"
protocol_display_name: "Assessment Protocol"
protocol_description: "This protocol is for assessing cognitive skills."
redcap_version: "X.XX.X"

CLI Usage

The `redcap2reproschema`` function has been integrated into a CLI tool, use the following command:

reproschema redcap2reproschema path/to/your_redcap_data_dic.csv path/to/your_redcap2rs.yaml

Optionally you can provide a path to the output directory (default is the current directory) by adding the option: --output-path PATH

Python Function Usage

You can also use the redcap2reproschema function from the reproschema-py package in your Python code.

from reproschema import redcap2reproschema

csv_path = "path-to/your_redcap_data_dic.csv"
yaml_path = "path-to/your_redcap2rs.yaml"
output_path = "path-to/directory_you_want_to_save_output"

redcap2reproschema(csv_file, yaml_file, output_path)

Notes

  1. The script requires an active internet connection to access the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reproschema-0.8.0.tar.gz (58.7 kB view details)

Uploaded Source

Built Distribution

reproschema-0.8.0-py3-none-any.whl (87.9 kB view details)

Uploaded Python 3

File details

Details for the file reproschema-0.8.0.tar.gz.

File metadata

  • Download URL: reproschema-0.8.0.tar.gz
  • Upload date:
  • Size: 58.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for reproschema-0.8.0.tar.gz
Algorithm Hash digest
SHA256 4a781e7b92bd6bd7f6f4090218312e875ea582ff1492828935d6bd1b30f6c060
MD5 96488897de6d515393a29e44ae4fb36a
BLAKE2b-256 0639d686b16e24a8c3d8cc10645976c46c1b554ab2faa1bd11b72ec2ce81abba

See more details on using hashes here.

File details

Details for the file reproschema-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: reproschema-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 87.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for reproschema-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7828a2476ce92efaa85e972bf88ef98477309ce71e1abdf88b73d8188d90f2e7
MD5 8747258f70edcb9a5828b83f9dbc573b
BLAKE2b-256 5040e76d54eba006f66b1b4dd3c0fedfe2c3899e451107bde3bbc3477f296698

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page