{"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1856 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1856\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9369 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9369\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: collection_date, specimen_type, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['collection_date', 'specimen_type', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: visit_id, collection_date, specimen_type. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'collection_date', 'specimen_type']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-5339 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-5339\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: fastq_1, assay, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'assay', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: visit_id, specimen_type, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'specimen_type', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2904 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2904\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: collection_date, subject_id, specimen_type. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['collection_date', 'subject_id', 'specimen_type']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9637 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9637\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8457 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8457\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1196 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1196\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: run_id, sample_id, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'sample_id', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8470 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8470\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9374 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9374\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8776 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8776\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: run_id, sample_id, fastq_1. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'sample_id', 'fastq_1']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2676 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2676\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: specimen_type, visit_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['specimen_type', 'visit_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-4121 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-4121\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: run_id, fastq_2, assay. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'fastq_2', 'assay']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: visit_id, subject_id, collection_date. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'subject_id', 'collection_date']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: collection_date, specimen_type, visit_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['collection_date', 'specimen_type', 'visit_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: sample_id, fastq_1, assay. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'fastq_1', 'assay']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-5377 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-5377\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: visit_id, specimen_type, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'specimen_type', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: collection_date, visit_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['collection_date', 'visit_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6449 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6449\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9820 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9820\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: fastq_1, fastq_2, run_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'fastq_2', 'run_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-7721 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-7721\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6646 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6646\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-5351 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-5351\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: site_id, sample_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['site_id', 'sample_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://lab-archive-example/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://lab-archive-example/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2875 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2875\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: assay, run_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['assay', 'run_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1865 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1865\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6952 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6952\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: sample_id, subject_id, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'subject_id', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: visit_id, collection_date, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'collection_date', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: site_id, subject_id, file_path. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['site_id', 'subject_id', 'file_path']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: subject_id, sample_id, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'sample_id', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3224 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3224\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2575 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2575\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6428 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6428\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6779 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6779\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8956 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8956\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2141 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2141\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-7794 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-7794\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1786 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1786\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2405 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2405\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6337 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6337\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: assay, sample_id, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['assay', 'sample_id', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2808 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2808\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: fastq_1, sample_id, run_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'sample_id', 'run_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-7711 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-7711\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: subject_id, file_path, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'file_path', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: sample_id, file_path, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'file_path', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-7854 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-7854\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: specimen_type, collection_date, visit_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['specimen_type', 'collection_date', 'visit_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: run_id, fastq_1, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'fastq_1', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-4010 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-4010\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8026 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8026\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: file_path, site_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['file_path', 'site_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: file_path, sample_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['file_path', 'sample_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6629 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6629\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: sample_id, file_path, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'file_path', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: subject_id, site_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'site_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: specimen_type, visit_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['specimen_type', 'visit_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-4555 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-4555\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3155 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3155\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://lab-archive-example/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://lab-archive-example/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: assay, fastq_2, run_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['assay', 'fastq_2', 'run_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: file_path, subject_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['file_path', 'subject_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6265 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6265\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: fastq_1, fastq_2, assay. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'fastq_2', 'assay']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: collection_date, specimen_type, visit_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['collection_date', 'specimen_type', 'visit_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: run_id, sample_id, assay. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'sample_id', 'assay']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: specimen_type, collection_date, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['specimen_type', 'collection_date', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://research-demo-landing-zone/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://research-demo-landing-zone/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: sample_id, run_id, assay. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'run_id', 'assay']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: sample_id, fastq_2, run_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'fastq_2', 'run_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: sample_id, subject_id, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'subject_id', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: visit_id, subject_id, collection_date. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'subject_id', 'collection_date']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: subject_id, file_path, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'file_path', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1186 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1186\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: sample_id, file_path, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'file_path', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: visit_id, specimen_type, collection_date. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'specimen_type', 'collection_date']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: assay, fastq_1, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['assay', 'fastq_1', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: subject_id, specimen_type, visit_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'specimen_type', 'visit_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6266 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6266\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3656 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3656\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://lab-archive-example/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://lab-archive-example/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://lab-archive-example/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3966 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3966\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: sample_id, file_path, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'file_path', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2136 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2136\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: specimen_type, collection_date, visit_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['specimen_type', 'collection_date', 'visit_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-7233 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-7233\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: file_path, subject_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['file_path', 'subject_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: fastq_1, run_id, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'run_id', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: sample_id, file_path, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'file_path', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3959 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3959\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2179 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2179\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: subject_id, file_path, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'file_path', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: sample_id, site_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'site_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9679 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9679\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: run_id, assay, fastq_1. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'assay', 'fastq_1']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: visit_id, collection_date, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'collection_date', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: assay, fastq_1, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['assay', 'fastq_1', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: fastq_1, run_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'run_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2380 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2380\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: run_id, sample_id, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'sample_id', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: visit_id, subject_id, specimen_type. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['visit_id', 'subject_id', 'specimen_type']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9088 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9088\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6523 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6523\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: fastq_1, assay, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'assay', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9863 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9863\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8259 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8259\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: assay, fastq_1, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['assay', 'fastq_1', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: run_id, sample_id, assay. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'sample_id', 'assay']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: subject_id, sample_id, file_path. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'sample_id', 'file_path']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: sample_id, site_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'site_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: subject_id, sample_id, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'sample_id', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: subject_id, site_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'site_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: subject_id, specimen_type, collection_date. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'specimen_type', 'collection_date']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: site_id, subject_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['site_id', 'subject_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-4181 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-4181\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-5026 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-5026\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: sample_id, site_id, file_path. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'site_id', 'file_path']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-4981 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-4981\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: subject_id, sample_id, file_path. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'sample_id', 'file_path']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: fastq_1, assay, fastq_2. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'assay', 'fastq_2']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3717 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3717\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-4139 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-4139\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1966 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1966\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6984 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6984\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: specimen_type, visit_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['specimen_type', 'visit_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8099 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8099\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2413 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2413\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2316 from site BOS02 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-2316\",\n \"site_id\": \"BOS02\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1115 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1115\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-7210 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-7210\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: collection_date, subject_id, specimen_type. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['collection_date', 'subject_id', 'specimen_type']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: file_path, site_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['file_path', 'site_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: subject_id, sample_id, site_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'sample_id', 'site_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: sample_id, fastq_2, run_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'fastq_2', 'run_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://research-demo-landing-zone/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://research-demo-landing-zone/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `rna_seq_qc`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `rna_seq_qc` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nrna_seq_qc/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3936 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3936\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-1826 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-1826\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-9756 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-9756\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://research-demo-landing-zone/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://research-demo-landing-zone/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-4746 from site NYC01 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-4746\",\n \"site_id\": \"NYC01\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `run_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"run_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://open-bio-demo-results/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://open-bio-demo-results/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://open-bio-demo-results/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/analysis` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/analysis\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3511 from site SEA06 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3511\",\n \"site_id\": \"SEA06\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `15 4 * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n15 4 * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `15`\n- hour: `4`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n15 4 * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: site_id, sample_id, subject_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['site_id', 'sample_id', 'subject_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `proteomics_upload`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `proteomics_upload` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nproteomics_upload/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-8917 from site PHL03 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-8917\",\n \"site_id\": \"PHL03\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://lab-archive-example/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://lab-archive-example/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `sequencing_manifest.csv`. The required columns are: sample_id, subject_id, file_path. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `sequencing_manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['sample_id', 'subject_id', 'file_path']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"sequencing_manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `imaging_metadata`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `imaging_metadata` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nimaging_metadata/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/data/project` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/data/project\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://open-bio-demo-results/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://open-bio-demo-results/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://open-bio-demo-results/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://lab-archive-example/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://lab-archive-example/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./manifests` to `s3://research-demo-landing-zone/raw/fastq`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./manifests\" \"s3://research-demo-landing-zone/raw/fastq\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./manifests` is the local source folder.\n- `s3://research-demo-landing-zone/raw/fastq` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: assay, sample_id, fastq_1. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['assay', 'sample_id', 'fastq_1']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 2 * * 1`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 2 * * 1\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `2`\n- day of month: `*`\n- month: `*`\n- day of week: `1`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 2 * * 1 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://lab-archive-example/processed/qc`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/processed/qc\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/processed/qc\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://lab-archive-example/processed/qc` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./analysis_output` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./analysis_output\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./analysis_output` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: subject_id, site_id, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'site_id', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: subject_id, collection_date, specimen_type. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'collection_date', 'specimen_type']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://open-bio-demo-results/metadata/manifests`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://open-bio-demo-results/metadata/manifests\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://open-bio-demo-results/metadata/manifests` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: run_id, fastq_1, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', 'fastq_1', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./qc_reports` to `s3://lab-archive-example/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./qc_reports\" \"s3://lab-archive-example/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./qc_reports` is the local source folder.\n- `s3://lab-archive-example/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-6950 from site SFO05 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-6950\",\n \"site_id\": \"SFO05\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `manifest.csv`. The required columns are: collection_date, subject_id, visit_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['collection_date', 'subject_id', 'visit_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"manifest.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: subject_id, site_id, file_path. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'site_id', 'file_path']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/results` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/results\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `metadata.csv`. The required columns are: fastq_1, fastq_2, sample_id. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `metadata.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['fastq_1', 'fastq_2', 'sample_id']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"metadata.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `sample_manifest`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `sample_manifest` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nsample_manifest/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `0 6 1 * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n0 6 1 * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `0`\n- hour: `6`\n- day of month: `1`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n0 6 1 * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `30 23 * * 5`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n30 23 * * 5\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `30`\n- hour: `23`\n- day of month: `*`\n- month: `*`\n- day of week: `5`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n30 23 * * 5 /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `specimen_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"specimen_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that scans a folder for FASTQ files ending in `.fastq.gz` and creates a CSV manifest with sample_id, read_pair, and file_path. Assume filenames look like SAMPLE123_R1.fastq.gz or SAMPLE123_R2.fastq.gz."}, {"role": "assistant", "content": "Here is a simple FASTQ manifest builder:\n\n```python\nfrom pathlib import Path\nimport csv\nimport re\nimport sys\n\nFASTQ_PATTERN = re.compile(r\"(?P.+)_(?PR[12])\\.fastq\\.gz$\")\n\n\ndef build_manifest(input_dir: str, output_csv: str) -> None:\n input_path = Path(input_dir)\n\n if not input_path.exists():\n raise FileNotFoundError(f\"Input directory does not exist: {input_dir}\")\n\n rows = []\n\n for fastq in sorted(input_path.rglob(\"*.fastq.gz\")):\n match = FASTQ_PATTERN.match(fastq.name)\n if not match:\n continue\n\n rows.append({\n \"sample_id\": match.group(\"sample_id\"),\n \"read_pair\": match.group(\"read_pair\"),\n \"file_path\": str(fastq.resolve()),\n })\n\n with open(output_csv, \"w\", newline=\"\", encoding=\"utf-8\") as handle:\n writer = csv.DictWriter(handle, fieldnames=[\"sample_id\", \"read_pair\", \"file_path\"])\n writer.writeheader()\n writer.writerows(rows)\n\n print(f\"Wrote {len(rows)} FASTQ records to {output_csv}\")\n\n\nif __name__ == \"__main__\":\n input_dir = sys.argv[1]\n output_csv = sys.argv[2]\n build_manifest(input_dir, output_csv)\n```\n\nThis script recursively scans folders, extracts sample IDs and read-pair labels, and writes a reproducible manifest.\n"}], "meta": {"task_type": "fastq_manifest", "expected_keywords": ["fastq.gz", "sample_id", "R1", "R2", "csv"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write an AWS CLI command to sync `./results` to `s3://research-demo-landing-zone/reports/monthly`. Include a dry-run version first and a real sync version. Also explain what each important flag does."}, {"role": "assistant", "content": "Use the dry-run command first:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --dryrun \\\n --only-show-errors\n```\n\nAfter reviewing the dry-run output, run the real sync:\n\n```bash\naws s3 sync \"./results\" \"s3://research-demo-landing-zone/reports/monthly\" \\\n --only-show-errors\n```\n\nExplanation:\n\n- `aws s3 sync` copies new or changed files between a local folder and S3.\n- `./results` is the local source folder.\n- `s3://research-demo-landing-zone/reports/monthly` is the destination S3 path.\n- `--dryrun` previews what would be copied without uploading anything.\n- `--only-show-errors` keeps the output cleaner by hiding routine transfer messages.\n"}], "meta": {"task_type": "aws_s3", "expected_keywords": ["aws s3 sync", "--dryrun", "--only-show-errors", "S3"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `assay` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"assay\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Generate a bash script that checks whether `/mnt/data` is mounted. If it is not mounted, print an error and exit with a non-zero status code. If it is mounted, print available disk space."}, {"role": "assistant", "content": "Here is a safe bash script:\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n\nMOUNT_POINT=\"/mnt/data\"\n\nif ! mountpoint -q \"$MOUNT_POINT\"; then\n echo \"ERROR: $MOUNT_POINT is not mounted.\" >&2\n exit 1\nfi\n\necho \"Mount point is available: $MOUNT_POINT\"\necho \"Disk usage:\"\ndf -h \"$MOUNT_POINT\"\n```\n\nExplanation:\n\n- `set -euo pipefail` makes the script fail more safely.\n- `mountpoint -q` checks whether the path is actually a mounted filesystem.\n- `>&2` sends the error message to standard error.\n- `exit 1` signals failure to a scheduler or pipeline.\n- `df -h` prints human-readable disk usage.\n"}], "meta": {"task_type": "bash_mount_check", "expected_keywords": ["mountpoint", "df -h", "exit 1", "set -euo pipefail"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `site_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"site_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `sample_id` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"sample_id\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-3115 from site CHI04 because the destination S3 prefix was missing.` Use keys: sample_id, site_id, problem, recommended_action."}, {"role": "assistant", "content": "```json\n{\n \"sample_id\": \"S-3115\",\n \"site_id\": \"CHI04\",\n \"problem\": \"The transfer failed because the destination S3 prefix was missing.\",\n \"recommended_action\": \"Create or correct the destination S3 prefix, then rerun the transfer after confirming the target path.\"\n}\n```"}], "meta": {"task_type": "json_extraction", "expected_keywords": ["sample_id", "site_id", "recommended_action"], "requires_json": true}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Convert this manual workflow into a reproducible checklist for `variant_calling`: download files, check row counts, validate required columns, archive the raw input, run the analysis script, save logs, and upload results."}, {"role": "assistant", "content": "A reproducible checklist for `variant_calling` could look like this:\n\n1. Create a dated run folder.\n2. Download or receive the input files.\n3. Save raw files in a read-only `raw/` folder.\n4. Record file names, sizes, and checksums.\n5. Validate row counts and required columns.\n6. Run the analysis script with explicit command-line arguments.\n7. Save stdout and stderr logs.\n8. Write outputs to a versioned `results/` folder.\n9. Upload final outputs to the approved destination.\n10. Record the software version, run date, and operator.\n\nExample folder layout:\n\n```text\nvariant_calling/\n raw/\n scripts/\n logs/\n results/\n manifests/\n```\n\nThis structure makes the workflow easier to audit, rerun, and debug.\n"}], "meta": {"task_type": "workflow_checklist", "expected_keywords": ["raw", "logs", "results", "checksums", "reproducible"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Explain this cron expression in plain English: `*/15 * * * *`. Also give one example of a data-engineering task that might use it."}, {"role": "assistant", "content": "The cron expression is:\n\n```text\n*/15 * * * *\n```\n\nCron fields are interpreted as:\n\n```text\nminute hour day-of-month month day-of-week\n```\n\nFor this expression:\n\n- minute: `*/15`\n- hour: `*`\n- day of month: `*`\n- month: `*`\n- day of week: `*`\n\nA data-engineering use case would be scheduling a recurring job that checks whether expected files arrived, validates a manifest, or syncs completed analysis results to object storage.\n\nExample command entry:\n\n```cron\n*/15 * * * * /usr/local/bin/run_manifest_validation.sh >> /var/log/manifest_validation.log 2>&1\n```\n\nThe `>>` appends logs to a file, and `2>&1` sends error output to the same log.\n"}], "meta": {"task_type": "cron_explanation", "expected_keywords": ["minute", "hour", "day", "log"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a pandas function that groups a DataFrame by `subject_id` and reports duplicate `file_path` values within each group. Return a DataFrame of problems."}, {"role": "assistant", "content": "Here is a pandas function for that check:\n\n```python\nimport pandas as pd\n\n\ndef find_duplicates_within_group(\n df: pd.DataFrame,\n group_col: str = \"subject_id\",\n value_col: str = \"file_path\",\n) -> pd.DataFrame:\n required = {group_col, value_col}\n missing = required - set(df.columns)\n if missing:\n raise ValueError(f\"Missing required columns: {sorted(missing)}\")\n\n duplicated_rows = df[df.duplicated(subset=[group_col, value_col], keep=False)].copy()\n\n if duplicated_rows.empty:\n return pd.DataFrame(columns=[group_col, value_col, \"duplicate_count\"])\n\n summary = (\n duplicated_rows\n .groupby([group_col, value_col])\n .size()\n .reset_index(name=\"duplicate_count\")\n .sort_values([\"duplicate_count\", group_col], ascending=[False, True])\n )\n\n return summary\n```\n\nThis returns only problematic group/value combinations, which makes it easier to review duplicate sample or file records.\n"}], "meta": {"task_type": "pandas_duplicate_check", "expected_keywords": ["pandas", "groupby", "duplicated", "duplicate_count"], "requires_json": false}} {"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, scientific data organization, and reproducible workflows. When you write code, prefer clear comments, safe defaults, and practical error handling."}, {"role": "user", "content": "Write a Python script that validates a CSV file named `samples.csv`. The required columns are: subject_id, site_id, file_path. The script should report missing columns, empty values in required columns, duplicate sample IDs if sample_id exists, and print a short summary."}, {"role": "assistant", "content": "Below is a practical validation script for `samples.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['subject_id', 'site_id', 'file_path']\n\n\ndef validate_csv(path: str) -> int:\n errors = []\n\n try:\n df = pd.read_csv(path)\n except FileNotFoundError:\n print(f\"ERROR: File not found: {path}\")\n return 1\n except Exception as exc:\n print(f\"ERROR: Could not read CSV: {exc}\")\n return 1\n\n missing_columns = [col for col in REQUIRED_COLUMNS if col not in df.columns]\n if missing_columns:\n errors.append(f\"Missing required columns: {missing_columns}\")\n\n for col in REQUIRED_COLUMNS:\n if col in df.columns:\n empty_count = df[col].isna().sum() + (df[col].astype(str).str.strip() == \"\").sum()\n if empty_count > 0:\n errors.append(f\"Column '{col}' has {empty_count} empty values\")\n\n if \"sample_id\" in df.columns:\n duplicate_count = df[\"sample_id\"].duplicated().sum()\n if duplicate_count > 0:\n errors.append(f\"Found {duplicate_count} duplicate sample_id values\")\n\n print(\"CSV validation summary\")\n print(f\"Rows: {len(df)}\")\n print(f\"Columns: {len(df.columns)}\")\n\n if errors:\n print(\"\\nValidation failed:\")\n for error in errors:\n print(f\"- {error}\")\n return 1\n\n print(\"Validation passed.\")\n return 0\n\n\nif __name__ == \"__main__\":\n csv_path = sys.argv[1] if len(sys.argv) > 1 else \"samples.csv\"\n raise SystemExit(validate_csv(csv_path))\n```\n\nThis script exits with status code `0` when the file passes validation and `1` when it finds problems.\n"}], "meta": {"task_type": "csv_validation", "expected_keywords": ["pandas", "required columns", "duplicate", "sample_id", "Validation"], "requires_json": false}}