{"messages": [{"role": "system", "content": "You are a careful bioinformatics and data-engineering coding assistant. You help with Python, pandas, bash, AWS CLI, cron, file validation, 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-8553 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-8553\",\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/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": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2718 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-2718\",\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": "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 `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": "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-2470 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-2470\",\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 `/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, 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 = ['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 \"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://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": "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: `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 `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 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 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": "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 `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": "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": "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: run_id, 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 `manifest.csv`.\n\n```python\nimport sys\nimport pandas as pd\n\nREQUIRED_COLUMNS = ['run_id', '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 \"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-5159 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-5159\",\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: 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": "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-6558 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-6558\",\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 `./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 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 `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 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": "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 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/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-8235 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-8235\",\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-5213 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-5213\",\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 `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-8156 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-8156\",\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": "Return a JSON object that summarizes a failed data transfer. The message is: `Transfer failed for sample S-2128 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-2128\",\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/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 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 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": "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 `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 `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 `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 Python script that validates a CSV file named `samples.csv`. The required columns are: fastq_2, 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 = ['fastq_2', '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 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 `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/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 `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": "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": "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 `./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 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, 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 `metadata.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 \"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 `samples.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 `samples.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 \"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": "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": "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-3092 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-3092\",\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: 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 `samples.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 \"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-1511 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-1511\",\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 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 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}}