opencode-knowledge-work 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (472) hide show
  1. package/LICENSE +212 -0
  2. package/README.md +124 -2
  3. package/content/bio-research/.mcp.json +48 -0
  4. package/content/bio-research/CONNECTORS.md +23 -0
  5. package/content/bio-research/LICENSE +202 -0
  6. package/content/bio-research/README.md +83 -0
  7. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/LICENSE.txt +201 -0
  8. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/SKILL.md +280 -0
  9. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/references/asm_schema_overview.md +226 -0
  10. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/references/field_classification_guide.md +503 -0
  11. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/references/flattening_guide.md +254 -0
  12. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/references/supported_instruments.md +151 -0
  13. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/requirements.txt +26 -0
  14. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/scripts/convert_to_asm.py +543 -0
  15. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/scripts/export_parser.py +481 -0
  16. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/scripts/flatten_asm.py +254 -0
  17. package/content/bio-research/skills/bio-research-instrument-data-to-allotrope/scripts/validate_asm.py +1102 -0
  18. package/content/bio-research/skills/bio-research-nextflow-development/LICENSE.txt +201 -0
  19. package/content/bio-research/skills/bio-research-nextflow-development/SKILL.md +290 -0
  20. package/content/bio-research/skills/bio-research-nextflow-development/references/geo-sra-acquisition.md +416 -0
  21. package/content/bio-research/skills/bio-research-nextflow-development/references/installation.md +96 -0
  22. package/content/bio-research/skills/bio-research-nextflow-development/references/pipelines/atacseq.md +138 -0
  23. package/content/bio-research/skills/bio-research-nextflow-development/references/pipelines/rnaseq.md +118 -0
  24. package/content/bio-research/skills/bio-research-nextflow-development/references/pipelines/sarek.md +145 -0
  25. package/content/bio-research/skills/bio-research-nextflow-development/references/troubleshooting.md +137 -0
  26. package/content/bio-research/skills/bio-research-nextflow-development/scripts/check_environment.py +452 -0
  27. package/content/bio-research/skills/bio-research-nextflow-development/scripts/config/genomes.yaml +148 -0
  28. package/content/bio-research/skills/bio-research-nextflow-development/scripts/config/pipelines/atacseq.yaml +187 -0
  29. package/content/bio-research/skills/bio-research-nextflow-development/scripts/config/pipelines/rnaseq.yaml +147 -0
  30. package/content/bio-research/skills/bio-research-nextflow-development/scripts/config/pipelines/sarek.yaml +233 -0
  31. package/content/bio-research/skills/bio-research-nextflow-development/scripts/detect_data_type.py +300 -0
  32. package/content/bio-research/skills/bio-research-nextflow-development/scripts/generate_samplesheet.py +455 -0
  33. package/content/bio-research/skills/bio-research-nextflow-development/scripts/manage_genomes.py +521 -0
  34. package/content/bio-research/skills/bio-research-nextflow-development/scripts/sra_geo_fetch.py +732 -0
  35. package/content/bio-research/skills/bio-research-nextflow-development/scripts/utils/__init__.py +69 -0
  36. package/content/bio-research/skills/bio-research-nextflow-development/scripts/utils/file_discovery.py +189 -0
  37. package/content/bio-research/skills/bio-research-nextflow-development/scripts/utils/ncbi_utils.py +808 -0
  38. package/content/bio-research/skills/bio-research-nextflow-development/scripts/utils/sample_inference.py +290 -0
  39. package/content/bio-research/skills/bio-research-nextflow-development/scripts/utils/validators.py +256 -0
  40. package/content/bio-research/skills/bio-research-scientific-problem-selection/LICENSE.txt +201 -0
  41. package/content/bio-research/skills/bio-research-scientific-problem-selection/SKILL.md +269 -0
  42. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/01-intuition-pumps.md +264 -0
  43. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/02-risk-assessment.md +323 -0
  44. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/03-optimization-function.md +481 -0
  45. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/04-parameter-strategy.md +396 -0
  46. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/05-decision-tree.md +85 -0
  47. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/06-adversity-planning.md +123 -0
  48. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/07-problem-inversion.md +152 -0
  49. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/08-integration-synthesis.md +173 -0
  50. package/content/bio-research/skills/bio-research-scientific-problem-selection/references/09-meta-framework.md +504 -0
  51. package/content/bio-research/skills/bio-research-scvi-tools/LICENSE.txt +201 -0
  52. package/content/bio-research/skills/bio-research-scvi-tools/SKILL.md +155 -0
  53. package/content/bio-research/skills/bio-research-scvi-tools/references/atac_peakvi.md +398 -0
  54. package/content/bio-research/skills/bio-research-scvi-tools/references/batch_correction_sysvi.md +417 -0
  55. package/content/bio-research/skills/bio-research-scvi-tools/references/citeseq_totalvi.md +420 -0
  56. package/content/bio-research/skills/bio-research-scvi-tools/references/data_preparation.md +286 -0
  57. package/content/bio-research/skills/bio-research-scvi-tools/references/environment_setup.md +254 -0
  58. package/content/bio-research/skills/bio-research-scvi-tools/references/label_transfer.md +373 -0
  59. package/content/bio-research/skills/bio-research-scvi-tools/references/multiome_multivi.md +384 -0
  60. package/content/bio-research/skills/bio-research-scvi-tools/references/rna_velocity_velovi.md +410 -0
  61. package/content/bio-research/skills/bio-research-scvi-tools/references/scarches_mapping.md +401 -0
  62. package/content/bio-research/skills/bio-research-scvi-tools/references/scrna_integration.md +429 -0
  63. package/content/bio-research/skills/bio-research-scvi-tools/references/spatial_deconvolution.md +438 -0
  64. package/content/bio-research/skills/bio-research-scvi-tools/references/troubleshooting.md +420 -0
  65. package/content/bio-research/skills/bio-research-scvi-tools/scripts/cluster_embed.py +212 -0
  66. package/content/bio-research/skills/bio-research-scvi-tools/scripts/differential_expression.py +220 -0
  67. package/content/bio-research/skills/bio-research-scvi-tools/scripts/integrate_datasets.py +237 -0
  68. package/content/bio-research/skills/bio-research-scvi-tools/scripts/model_utils.py +634 -0
  69. package/content/bio-research/skills/bio-research-scvi-tools/scripts/prepare_data.py +169 -0
  70. package/content/bio-research/skills/bio-research-scvi-tools/scripts/train_model.py +370 -0
  71. package/content/bio-research/skills/bio-research-scvi-tools/scripts/transfer_labels.py +224 -0
  72. package/content/bio-research/skills/bio-research-scvi-tools/scripts/validate_adata.py +397 -0
  73. package/content/bio-research/skills/bio-research-single-cell-rna-qc/LICENSE.txt +201 -0
  74. package/content/bio-research/skills/bio-research-single-cell-rna-qc/SKILL.md +175 -0
  75. package/content/bio-research/skills/bio-research-single-cell-rna-qc/references/scverse_qc_guidelines.md +186 -0
  76. package/content/bio-research/skills/bio-research-single-cell-rna-qc/scripts/qc_analysis.py +232 -0
  77. package/content/bio-research/skills/bio-research-single-cell-rna-qc/scripts/qc_core.py +233 -0
  78. package/content/bio-research/skills/bio-research-single-cell-rna-qc/scripts/qc_plotting.py +235 -0
  79. package/content/bio-research/skills/bio-research-start/SKILL.md +79 -0
  80. package/content/customer-support/.mcp.json +40 -0
  81. package/content/customer-support/CONNECTORS.md +19 -0
  82. package/content/customer-support/LICENSE +202 -0
  83. package/content/customer-support/README.md +140 -0
  84. package/content/customer-support/skills/customer-support-customer-escalation/SKILL.md +248 -0
  85. package/content/customer-support/skills/customer-support-customer-research/SKILL.md +252 -0
  86. package/content/customer-support/skills/customer-support-draft-response/SKILL.md +418 -0
  87. package/content/customer-support/skills/customer-support-kb-article/SKILL.md +351 -0
  88. package/content/customer-support/skills/customer-support-ticket-triage/SKILL.md +275 -0
  89. package/content/data/.mcp.json +36 -0
  90. package/content/data/CONNECTORS.md +18 -0
  91. package/content/data/LICENSE +202 -0
  92. package/content/data/README.md +121 -0
  93. package/content/data/skills/data-analyze/SKILL.md +119 -0
  94. package/content/data/skills/data-build-dashboard/SKILL.md +924 -0
  95. package/content/data/skills/data-create-viz/SKILL.md +154 -0
  96. package/content/data/skills/data-data-context-extractor/SKILL.md +227 -0
  97. package/content/data/skills/data-data-context-extractor/references/domain-template.md +147 -0
  98. package/content/data/skills/data-data-context-extractor/references/example-output.md +198 -0
  99. package/content/data/skills/data-data-context-extractor/references/skill-template.md +148 -0
  100. package/content/data/skills/data-data-context-extractor/references/sql-dialects.md +121 -0
  101. package/content/data/skills/data-data-context-extractor/scripts/package_data_skill.py +126 -0
  102. package/content/data/skills/data-data-visualization/SKILL.md +305 -0
  103. package/content/data/skills/data-explore-data/SKILL.md +325 -0
  104. package/content/data/skills/data-sql-queries/SKILL.md +428 -0
  105. package/content/data/skills/data-statistical-analysis/SKILL.md +245 -0
  106. package/content/data/skills/data-validate-data/SKILL.md +383 -0
  107. package/content/data/skills/data-write-query/SKILL.md +122 -0
  108. package/content/design/.mcp.json +44 -0
  109. package/content/design/CONNECTORS.md +18 -0
  110. package/content/design/README.md +117 -0
  111. package/content/design/skills/design-accessibility-review/SKILL.md +128 -0
  112. package/content/design/skills/design-design-critique/SKILL.md +118 -0
  113. package/content/design/skills/design-design-handoff/SKILL.md +131 -0
  114. package/content/design/skills/design-design-system/SKILL.md +190 -0
  115. package/content/design/skills/design-research-synthesis/SKILL.md +92 -0
  116. package/content/design/skills/design-user-research/SKILL.md +41 -0
  117. package/content/design/skills/design-ux-copy/SKILL.md +107 -0
  118. package/content/engineering/.mcp.json +48 -0
  119. package/content/engineering/CONNECTORS.md +19 -0
  120. package/content/engineering/README.md +136 -0
  121. package/content/engineering/skills/engineering-architecture/SKILL.md +85 -0
  122. package/content/engineering/skills/engineering-code-review/SKILL.md +118 -0
  123. package/content/engineering/skills/engineering-debug/SKILL.md +95 -0
  124. package/content/engineering/skills/engineering-deploy-checklist/SKILL.md +78 -0
  125. package/content/engineering/skills/engineering-documentation/SKILL.md +49 -0
  126. package/content/engineering/skills/engineering-incident-response/SKILL.md +158 -0
  127. package/content/engineering/skills/engineering-standup/SKILL.md +75 -0
  128. package/content/engineering/skills/engineering-system-design/SKILL.md +42 -0
  129. package/content/engineering/skills/engineering-tech-debt/SKILL.md +32 -0
  130. package/content/engineering/skills/engineering-testing-strategy/SKILL.md +33 -0
  131. package/content/enterprise-search/.mcp.json +36 -0
  132. package/content/enterprise-search/CONNECTORS.md +21 -0
  133. package/content/enterprise-search/LICENSE +202 -0
  134. package/content/enterprise-search/README.md +157 -0
  135. package/content/enterprise-search/skills/enterprise-search-digest/SKILL.md +173 -0
  136. package/content/enterprise-search/skills/enterprise-search-knowledge-synthesis/SKILL.md +258 -0
  137. package/content/enterprise-search/skills/enterprise-search-search/SKILL.md +178 -0
  138. package/content/enterprise-search/skills/enterprise-search-search-strategy/SKILL.md +222 -0
  139. package/content/enterprise-search/skills/enterprise-search-source-management/SKILL.md +173 -0
  140. package/content/finance/.mcp.json +32 -0
  141. package/content/finance/CONNECTORS.md +20 -0
  142. package/content/finance/LICENSE +202 -0
  143. package/content/finance/README.md +92 -0
  144. package/content/finance/skills/finance-audit-support/SKILL.md +374 -0
  145. package/content/finance/skills/finance-close-management/SKILL.md +221 -0
  146. package/content/finance/skills/finance-financial-statements/SKILL.md +335 -0
  147. package/content/finance/skills/finance-journal-entry/SKILL.md +131 -0
  148. package/content/finance/skills/finance-journal-entry-prep/SKILL.md +186 -0
  149. package/content/finance/skills/finance-reconciliation/SKILL.md +175 -0
  150. package/content/finance/skills/finance-sox-testing/SKILL.md +218 -0
  151. package/content/finance/skills/finance-variance-analysis/SKILL.md +266 -0
  152. package/content/human-resources/.mcp.json +28 -0
  153. package/content/human-resources/CONNECTORS.md +19 -0
  154. package/content/human-resources/README.md +138 -0
  155. package/content/human-resources/skills/human-resources-comp-analysis/SKILL.md +92 -0
  156. package/content/human-resources/skills/human-resources-draft-offer/SKILL.md +82 -0
  157. package/content/human-resources/skills/human-resources-interview-prep/SKILL.md +37 -0
  158. package/content/human-resources/skills/human-resources-onboarding/SKILL.md +104 -0
  159. package/content/human-resources/skills/human-resources-org-planning/SKILL.md +28 -0
  160. package/content/human-resources/skills/human-resources-people-report/SKILL.md +99 -0
  161. package/content/human-resources/skills/human-resources-performance-review/SKILL.md +149 -0
  162. package/content/human-resources/skills/human-resources-policy-lookup/SKILL.md +94 -0
  163. package/content/human-resources/skills/human-resources-recruiting-pipeline/SKILL.md +31 -0
  164. package/content/legal/.mcp.json +36 -0
  165. package/content/legal/CONNECTORS.md +21 -0
  166. package/content/legal/LICENSE +202 -0
  167. package/content/legal/README.md +234 -0
  168. package/content/legal/skills/legal-brief/SKILL.md +208 -0
  169. package/content/legal/skills/legal-compliance-check/SKILL.md +274 -0
  170. package/content/legal/skills/legal-legal-response/SKILL.md +457 -0
  171. package/content/legal/skills/legal-legal-risk-assessment/SKILL.md +265 -0
  172. package/content/legal/skills/legal-meeting-briefing/SKILL.md +220 -0
  173. package/content/legal/skills/legal-review-contract/SKILL.md +358 -0
  174. package/content/legal/skills/legal-signature-request/SKILL.md +104 -0
  175. package/content/legal/skills/legal-triage-nda/SKILL.md +262 -0
  176. package/content/legal/skills/legal-vendor-check/SKILL.md +159 -0
  177. package/content/manifest.json +86 -0
  178. package/content/marketing/.mcp.json +60 -0
  179. package/content/marketing/CONNECTORS.md +20 -0
  180. package/content/marketing/LICENSE +202 -0
  181. package/content/marketing/README.md +90 -0
  182. package/content/marketing/skills/marketing-brand-review/SKILL.md +276 -0
  183. package/content/marketing/skills/marketing-campaign-plan/SKILL.md +308 -0
  184. package/content/marketing/skills/marketing-competitive-brief/SKILL.md +331 -0
  185. package/content/marketing/skills/marketing-content-creation/SKILL.md +157 -0
  186. package/content/marketing/skills/marketing-draft-content/SKILL.md +117 -0
  187. package/content/marketing/skills/marketing-email-sequence/SKILL.md +220 -0
  188. package/content/marketing/skills/marketing-performance-report/SKILL.md +392 -0
  189. package/content/marketing/skills/marketing-seo-audit/SKILL.md +190 -0
  190. package/content/operations/.mcp.json +32 -0
  191. package/content/operations/CONNECTORS.md +20 -0
  192. package/content/operations/README.md +135 -0
  193. package/content/operations/skills/operations-capacity-plan/SKILL.md +113 -0
  194. package/content/operations/skills/operations-change-request/SKILL.md +121 -0
  195. package/content/operations/skills/operations-compliance-tracking/SKILL.md +44 -0
  196. package/content/operations/skills/operations-process-doc/SKILL.md +82 -0
  197. package/content/operations/skills/operations-process-optimization/SKILL.md +39 -0
  198. package/content/operations/skills/operations-risk-assessment/SKILL.md +40 -0
  199. package/content/operations/skills/operations-runbook/SKILL.md +87 -0
  200. package/content/operations/skills/operations-status-report/SKILL.md +77 -0
  201. package/content/operations/skills/operations-vendor-review/SKILL.md +104 -0
  202. package/content/pdf-viewer/.mcp.json +8 -0
  203. package/content/pdf-viewer/CONNECTORS.md +15 -0
  204. package/content/pdf-viewer/LICENSE +202 -0
  205. package/content/pdf-viewer/README.md +57 -0
  206. package/content/pdf-viewer/commands/annotate.md +51 -0
  207. package/content/pdf-viewer/commands/fill-form.md +73 -0
  208. package/content/pdf-viewer/commands/open.md +34 -0
  209. package/content/pdf-viewer/commands/sign.md +54 -0
  210. package/content/pdf-viewer/skills/pdf-viewer-view-pdf/SKILL.md +147 -0
  211. package/content/product-management/.mcp.json +72 -0
  212. package/content/product-management/CONNECTORS.md +22 -0
  213. package/content/product-management/LICENSE +202 -0
  214. package/content/product-management/README.md +118 -0
  215. package/content/product-management/commands/brainstorm.md +120 -0
  216. package/content/product-management/skills/product-management-competitive-brief/SKILL.md +302 -0
  217. package/content/product-management/skills/product-management-metrics-review/SKILL.md +388 -0
  218. package/content/product-management/skills/product-management-product-brainstorming/SKILL.md +273 -0
  219. package/content/product-management/skills/product-management-roadmap-update/SKILL.md +266 -0
  220. package/content/product-management/skills/product-management-sprint-planning/SKILL.md +94 -0
  221. package/content/product-management/skills/product-management-stakeholder-update/SKILL.md +352 -0
  222. package/content/product-management/skills/product-management-synthesize-research/SKILL.md +312 -0
  223. package/content/product-management/skills/product-management-write-spec/SKILL.md +250 -0
  224. package/content/productivity/.mcp.json +44 -0
  225. package/content/productivity/CONNECTORS.md +18 -0
  226. package/content/productivity/LICENSE +202 -0
  227. package/content/productivity/README.md +97 -0
  228. package/content/productivity/skills/dashboard.html +3111 -0
  229. package/content/productivity/skills/productivity-memory-management/SKILL.md +323 -0
  230. package/content/productivity/skills/productivity-start/SKILL.md +158 -0
  231. package/content/productivity/skills/productivity-task-management/SKILL.md +91 -0
  232. package/content/productivity/skills/productivity-update/SKILL.md +168 -0
  233. package/content/sales/.mcp.json +100 -0
  234. package/content/sales/CONNECTORS.md +36 -0
  235. package/content/sales/LICENSE +202 -0
  236. package/content/sales/README.md +148 -0
  237. package/content/sales/skills/sales-account-context/SKILL.md +94 -0
  238. package/content/sales/skills/sales-account-plan/SKILL.md +95 -0
  239. package/content/sales/skills/sales-account-research/SKILL.md +99 -0
  240. package/content/sales/skills/sales-account-tiering/SKILL.md +101 -0
  241. package/content/sales/skills/sales-call-prep/SKILL.md +111 -0
  242. package/content/sales/skills/sales-call-summary/SKILL.md +111 -0
  243. package/content/sales/skills/sales-close-plan/SKILL.md +106 -0
  244. package/content/sales/skills/sales-competitive-intelligence/SKILL.md +102 -0
  245. package/content/sales/skills/sales-create-an-asset/SKILL.md +105 -0
  246. package/content/sales/skills/sales-crm-hygiene-check/SKILL.md +103 -0
  247. package/content/sales/skills/sales-customer-health/SKILL.md +108 -0
  248. package/content/sales/skills/sales-customer-voice/SKILL.md +94 -0
  249. package/content/sales/skills/sales-daily-briefing/SKILL.md +61 -0
  250. package/content/sales/skills/sales-deal-advance-gap/SKILL.md +102 -0
  251. package/content/sales/skills/sales-deal-review/SKILL.md +105 -0
  252. package/content/sales/skills/sales-deal-signals/SKILL.md +96 -0
  253. package/content/sales/skills/sales-deal-slip-scenario/SKILL.md +101 -0
  254. package/content/sales/skills/sales-draft-outreach/SKILL.md +116 -0
  255. package/content/sales/skills/sales-end-of-day/SKILL.md +114 -0
  256. package/content/sales/skills/sales-expansion-whitespace/SKILL.md +97 -0
  257. package/content/sales/skills/sales-forecast/SKILL.md +100 -0
  258. package/content/sales/skills/sales-handle-objection/SKILL.md +93 -0
  259. package/content/sales/skills/sales-inbox-sweep/SKILL.md +114 -0
  260. package/content/sales/skills/sales-lead-triage/SKILL.md +105 -0
  261. package/content/sales/skills/sales-log-activity/SKILL.md +111 -0
  262. package/content/sales/skills/sales-pipeline-review/SKILL.md +97 -0
  263. package/content/sales/skills/sales-renewal-radar/SKILL.md +95 -0
  264. package/content/sales/skills/sales-rep-context/SKILL.md +90 -0
  265. package/content/sales/skills/sales-route-lead/SKILL.md +111 -0
  266. package/content/sales/skills/sales-schedule-meeting/SKILL.md +99 -0
  267. package/content/sales/skills/sales-setup/SKILL.md +195 -0
  268. package/content/sales/skills/sales-stakeholder-map/SKILL.md +107 -0
  269. package/content/sales/skills/sales-team-pipeline/SKILL.md +105 -0
  270. package/content/sales/skills/sales-update-opportunity/SKILL.md +111 -0
  271. package/content/sales/skills/sales-weekly-wrap/SKILL.md +90 -0
  272. package/content/sales/skills/sales-win-loss-review/SKILL.md +88 -0
  273. package/content/small-business/.mcp.json +148 -0
  274. package/content/small-business/README.md +117 -0
  275. package/content/small-business/skills/small-business-ad-manager/SKILL.md +128 -0
  276. package/content/small-business/skills/small-business-ad-manager/reference/ad_copy.md +112 -0
  277. package/content/small-business/skills/small-business-ad-manager/reference/change_playbook.md +127 -0
  278. package/content/small-business/skills/small-business-ad-manager/reference/data_sources.md +100 -0
  279. package/content/small-business/skills/small-business-ad-manager/reference/diagnostics.md +89 -0
  280. package/content/small-business/skills/small-business-ad-manager/reference/gotchas.md +181 -0
  281. package/content/small-business/skills/small-business-ap-processor/SKILL.md +158 -0
  282. package/content/small-business/skills/small-business-ap-processor/reference/coding_rules.md +70 -0
  283. package/content/small-business/skills/small-business-ap-processor/reference/gotchas.md +131 -0
  284. package/content/small-business/skills/small-business-ap-processor/reference/intake_and_extraction.md +82 -0
  285. package/content/small-business/skills/small-business-ap-processor/reference/matching_and_exceptions.md +80 -0
  286. package/content/small-business/skills/small-business-ap-processor/reference/payment_run.md +77 -0
  287. package/content/small-business/skills/small-business-brand-style/SKILL.md +106 -0
  288. package/content/small-business/skills/small-business-build-agent/SKILL.md +105 -0
  289. package/content/small-business/skills/small-business-build-agent/reference/capture.md +133 -0
  290. package/content/small-business/skills/small-business-build-agent/reference/gotchas.md +204 -0
  291. package/content/small-business/skills/small-business-build-agent/reference/skill_authoring.md +165 -0
  292. package/content/small-business/skills/small-business-build-connector/SKILL.md +102 -0
  293. package/content/small-business/skills/small-business-build-connector/reference/discovery.md +120 -0
  294. package/content/small-business/skills/small-business-build-connector/reference/gotchas.md +237 -0
  295. package/content/small-business/skills/small-business-build-connector/reference/paths.md +106 -0
  296. package/content/small-business/skills/small-business-build-connector/reference/use-zapier.md +128 -0
  297. package/content/small-business/skills/small-business-business-pulse/SKILL.md +181 -0
  298. package/content/small-business/skills/small-business-business-pulse/reference/data_sources.md +173 -0
  299. package/content/small-business/skills/small-business-business-pulse/reference/gotchas.md +103 -0
  300. package/content/small-business/skills/small-business-business-pulse/reference/output_template.md +109 -0
  301. package/content/small-business/skills/small-business-business-pulse/reference/thresholds.md +71 -0
  302. package/content/small-business/skills/small-business-business-pulse/reference/v2_sources.md +63 -0
  303. package/content/small-business/skills/small-business-call-list/SKILL.md +82 -0
  304. package/content/small-business/skills/small-business-canva-creator/SKILL.md +448 -0
  305. package/content/small-business/skills/small-business-canva-creator/reference/canva-api.md +208 -0
  306. package/content/small-business/skills/small-business-canva-creator/reference/examples/boutique-brief-campaign.md +181 -0
  307. package/content/small-business/skills/small-business-canva-creator/reference/gotchas.md +380 -0
  308. package/content/small-business/skills/small-business-canva-creator/reference/hubspot-staging.md +137 -0
  309. package/content/small-business/skills/small-business-cash-flow-snapshot/SKILL.md +251 -0
  310. package/content/small-business/skills/small-business-cash-flow-snapshot/reference/examples/worked-example.md +92 -0
  311. package/content/small-business/skills/small-business-cash-flow-snapshot/reference/gotchas.md +62 -0
  312. package/content/small-business/skills/small-business-cash-flow-snapshot/reference/v2_sources.md +84 -0
  313. package/content/small-business/skills/small-business-close-month/SKILL.md +86 -0
  314. package/content/small-business/skills/small-business-content-strategy/SKILL.md +152 -0
  315. package/content/small-business/skills/small-business-content-strategy/reference/examples/retail-boutique-example.md +71 -0
  316. package/content/small-business/skills/small-business-content-strategy/reference/gotchas.md +104 -0
  317. package/content/small-business/skills/small-business-content-strategy/reference/v2_sources.md +40 -0
  318. package/content/small-business/skills/small-business-contract-review/SKILL.md +158 -0
  319. package/content/small-business/skills/small-business-contract-review/reference/docusign-fetch.md +32 -0
  320. package/content/small-business/skills/small-business-contract-review/reference/examples/flagged-summary-saas.md +97 -0
  321. package/content/small-business/skills/small-business-contract-review/reference/gmail-fetch.md +30 -0
  322. package/content/small-business/skills/small-business-contract-review/reference/gotchas.md +105 -0
  323. package/content/small-business/skills/small-business-contract-review/reference/m365-fetch.md +60 -0
  324. package/content/small-business/skills/small-business-crm-autopilot/SKILL.md +162 -0
  325. package/content/small-business/skills/small-business-crm-autopilot/reference/cleanup-checklist.md +82 -0
  326. package/content/small-business/skills/small-business-crm-autopilot/reference/examples/cleanup-deal.md +83 -0
  327. package/content/small-business/skills/small-business-crm-autopilot/reference/examples/log-call-happy-path.md +68 -0
  328. package/content/small-business/skills/small-business-crm-autopilot/reference/examples/log-email-happy-path.md +50 -0
  329. package/content/small-business/skills/small-business-crm-autopilot/reference/gotchas.md +110 -0
  330. package/content/small-business/skills/small-business-crm-autopilot/reference/hubspot-fields.md +62 -0
  331. package/content/small-business/skills/small-business-crm-autopilot/reference/lightweight_crm.md +125 -0
  332. package/content/small-business/skills/small-business-crm-autopilot/reference/salesforce-fields.md +122 -0
  333. package/content/small-business/skills/small-business-crm-autopilot/reference/standing_mode.md +144 -0
  334. package/content/small-business/skills/small-business-grant-rfp-writer/SKILL.md +162 -0
  335. package/content/small-business/skills/small-business-grant-rfp-writer/reference/drafting.md +129 -0
  336. package/content/small-business/skills/small-business-grant-rfp-writer/reference/go_no_go.md +125 -0
  337. package/content/small-business/skills/small-business-grant-rfp-writer/reference/gotchas.md +180 -0
  338. package/content/small-business/skills/small-business-grant-rfp-writer/reference/opportunity_sources.md +90 -0
  339. package/content/small-business/skills/small-business-grant-rfp-writer/reference/org_profile.md +81 -0
  340. package/content/small-business/skills/small-business-grow-pipeline/SKILL.md +92 -0
  341. package/content/small-business/skills/small-business-growth-pulse/SKILL.md +143 -0
  342. package/content/small-business/skills/small-business-growth-pulse/reference/data_sources.md +113 -0
  343. package/content/small-business/skills/small-business-growth-pulse/reference/gotchas.md +175 -0
  344. package/content/small-business/skills/small-business-growth-pulse/reference/output_template.md +122 -0
  345. package/content/small-business/skills/small-business-growth-pulse/reference/thresholds.md +110 -0
  346. package/content/small-business/skills/small-business-hiring-screener/SKILL.md +137 -0
  347. package/content/small-business/skills/small-business-hiring-screener/reference/candidate_comms.md +132 -0
  348. package/content/small-business/skills/small-business-hiring-screener/reference/fair_screening.md +103 -0
  349. package/content/small-business/skills/small-business-hiring-screener/reference/gotchas.md +183 -0
  350. package/content/small-business/skills/small-business-hiring-screener/reference/onboarding.md +82 -0
  351. package/content/small-business/skills/small-business-hiring-screener/reference/rubric.md +122 -0
  352. package/content/small-business/skills/small-business-inbox-manager/SKILL.md +130 -0
  353. package/content/small-business/skills/small-business-inbox-manager/reference/digest_format.md +110 -0
  354. package/content/small-business/skills/small-business-inbox-manager/reference/gotchas.md +220 -0
  355. package/content/small-business/skills/small-business-inbox-manager/reference/handoffs.md +77 -0
  356. package/content/small-business/skills/small-business-inbox-manager/reference/reply_drafting.md +116 -0
  357. package/content/small-business/skills/small-business-inbox-manager/reference/triage_rules.md +72 -0
  358. package/content/small-business/skills/small-business-inventory-planner/SKILL.md +126 -0
  359. package/content/small-business/skills/small-business-inventory-planner/reference/data_sources.md +94 -0
  360. package/content/small-business/skills/small-business-inventory-planner/reference/gotchas.md +153 -0
  361. package/content/small-business/skills/small-business-inventory-planner/reference/po_drafting.md +92 -0
  362. package/content/small-business/skills/small-business-inventory-planner/reference/seasonality.md +112 -0
  363. package/content/small-business/skills/small-business-inventory-planner/reference/velocity_and_reorder.md +154 -0
  364. package/content/small-business/skills/small-business-invoice-chase/SKILL.md +131 -0
  365. package/content/small-business/skills/small-business-invoice-chase/reference/examples/firm-reminder.md +28 -0
  366. package/content/small-business/skills/small-business-invoice-chase/reference/examples/gentle-reminder.md +27 -0
  367. package/content/small-business/skills/small-business-invoice-chase/reference/gotchas.md +75 -0
  368. package/content/small-business/skills/small-business-invoice-chase/reference/tone-matching.md +44 -0
  369. package/content/small-business/skills/small-business-invoice-chase/reference/v2_sources.md +78 -0
  370. package/content/small-business/skills/small-business-job-post-builder/SKILL.md +204 -0
  371. package/content/small-business/skills/small-business-job-post-builder/reference/docusign-routing.md +63 -0
  372. package/content/small-business/skills/small-business-job-post-builder/reference/examples/worked-example.md +110 -0
  373. package/content/small-business/skills/small-business-job-post-builder/reference/existing-document-merge.md +58 -0
  374. package/content/small-business/skills/small-business-job-post-builder/reference/gotchas.md +68 -0
  375. package/content/small-business/skills/small-business-job-post-builder/reference/interview-guide-structure.md +93 -0
  376. package/content/small-business/skills/small-business-job-post-builder/reference/job-post-structure.md +62 -0
  377. package/content/small-business/skills/small-business-job-post-builder/reference/offer-letter-template.md +145 -0
  378. package/content/small-business/skills/small-business-job-post-builder/reference/role-intake.md +73 -0
  379. package/content/small-business/skills/small-business-lead-finder/SKILL.md +119 -0
  380. package/content/small-business/skills/small-business-lead-finder/reference/gotchas.md +152 -0
  381. package/content/small-business/skills/small-business-lead-finder/reference/icp_method.md +97 -0
  382. package/content/small-business/skills/small-business-lead-finder/reference/output_template.md +124 -0
  383. package/content/small-business/skills/small-business-lead-finder/reference/scoring.md +92 -0
  384. package/content/small-business/skills/small-business-lead-finder/reference/sourcing.md +78 -0
  385. package/content/small-business/skills/small-business-lead-triage/SKILL.md +81 -0
  386. package/content/small-business/skills/small-business-lead-triage/reference/examples/happy-path-triage.md +68 -0
  387. package/content/small-business/skills/small-business-lead-triage/reference/gotchas.md +76 -0
  388. package/content/small-business/skills/small-business-lead-triage/reference/hubspot-scoring.md +169 -0
  389. package/content/small-business/skills/small-business-marketing-monday/SKILL.md +108 -0
  390. package/content/small-business/skills/small-business-monday-brief/SKILL.md +97 -0
  391. package/content/small-business/skills/small-business-month-end-prep/SKILL.md +331 -0
  392. package/content/small-business/skills/small-business-month-end-prep/reference/close-packet-format.md +127 -0
  393. package/content/small-business/skills/small-business-month-end-prep/reference/examples/pl-narrative.md +52 -0
  394. package/content/small-business/skills/small-business-month-end-prep/reference/gotchas.md +113 -0
  395. package/content/small-business/skills/small-business-month-end-prep/reference/paypal-settlements.md +110 -0
  396. package/content/small-business/skills/small-business-month-end-prep/reference/quickbooks-reconcile.md +71 -0
  397. package/content/small-business/skills/small-business-month-end-prep/reference/v2_sources.md +125 -0
  398. package/content/small-business/skills/small-business-month-end-prep/reference/xero-reconcile.md +175 -0
  399. package/content/small-business/skills/small-business-month-end-prep/reference/zoho-books-reconcile.md +168 -0
  400. package/content/small-business/skills/small-business-outreach-composer/SKILL.md +144 -0
  401. package/content/small-business/skills/small-business-outreach-composer/reference/gotchas.md +213 -0
  402. package/content/small-business/skills/small-business-outreach-composer/reference/output_template.md +147 -0
  403. package/content/small-business/skills/small-business-outreach-composer/reference/sequence_patterns.md +99 -0
  404. package/content/small-business/skills/small-business-outreach-composer/reference/slop_test.md +164 -0
  405. package/content/small-business/skills/small-business-pay-the-bills/SKILL.md +101 -0
  406. package/content/small-business/skills/small-business-payroll-prep/SKILL.md +139 -0
  407. package/content/small-business/skills/small-business-payroll-prep/reference/anomaly_rules.md +99 -0
  408. package/content/small-business/skills/small-business-payroll-prep/reference/books_sync.md +72 -0
  409. package/content/small-business/skills/small-business-payroll-prep/reference/gotchas.md +153 -0
  410. package/content/small-business/skills/small-business-payroll-prep/reference/run_sheet_format.md +90 -0
  411. package/content/small-business/skills/small-business-payroll-prep/reference/timesheet_intake.md +118 -0
  412. package/content/small-business/skills/small-business-plan-payroll/SKILL.md +88 -0
  413. package/content/small-business/skills/small-business-proposal-builder/SKILL.md +168 -0
  414. package/content/small-business/skills/small-business-proposal-builder/reference/discovery_extraction.md +138 -0
  415. package/content/small-business/skills/small-business-proposal-builder/reference/gotchas.md +184 -0
  416. package/content/small-business/skills/small-business-proposal-builder/reference/output_template.md +128 -0
  417. package/content/small-business/skills/small-business-proposal-builder/reference/pricing_method.md +125 -0
  418. package/content/small-business/skills/small-business-proposal-builder/reference/proposal_structure.md +120 -0
  419. package/content/small-business/skills/small-business-reactivate/SKILL.md +109 -0
  420. package/content/small-business/skills/small-business-report-builder/SKILL.md +142 -0
  421. package/content/small-business/skills/small-business-report-builder/reference/data_sources.md +168 -0
  422. package/content/small-business/skills/small-business-report-builder/reference/gotchas.md +155 -0
  423. package/content/small-business/skills/small-business-report-builder/reference/output_template.md +109 -0
  424. package/content/small-business/skills/small-business-report-builder/reference/report_spec.md +109 -0
  425. package/content/small-business/skills/small-business-report-builder/reference/saved_reports.md +50 -0
  426. package/content/small-business/skills/small-business-report-pack/SKILL.md +83 -0
  427. package/content/small-business/skills/small-business-restock/SKILL.md +88 -0
  428. package/content/small-business/skills/small-business-review-reputation/SKILL.md +130 -0
  429. package/content/small-business/skills/small-business-review-reputation/reference/churn-signals.md +110 -0
  430. package/content/small-business/skills/small-business-review-reputation/reference/examples/example-report.md +150 -0
  431. package/content/small-business/skills/small-business-review-reputation/reference/gotchas.md +164 -0
  432. package/content/small-business/skills/small-business-review-reputation/reference/response-patterns.md +123 -0
  433. package/content/small-business/skills/small-business-review-reputation/reference/sources.md +116 -0
  434. package/content/small-business/skills/small-business-seo-ai-visibility/SKILL.md +143 -0
  435. package/content/small-business/skills/small-business-seo-ai-visibility/reference/ai_visibility.md +173 -0
  436. package/content/small-business/skills/small-business-seo-ai-visibility/reference/audit_checklist.md +134 -0
  437. package/content/small-business/skills/small-business-seo-ai-visibility/reference/catalog_refresh.md +126 -0
  438. package/content/small-business/skills/small-business-seo-ai-visibility/reference/content_rewrite.md +113 -0
  439. package/content/small-business/skills/small-business-seo-ai-visibility/reference/gotchas.md +211 -0
  440. package/content/small-business/skills/small-business-smb-onboard/SKILL.md +82 -0
  441. package/content/small-business/skills/small-business-smb-onboard/reference/examples/happy-path.md +190 -0
  442. package/content/small-business/skills/small-business-smb-onboard/reference/gotchas.md +111 -0
  443. package/content/small-business/skills/small-business-smb-onboard/reference/onboard-checklist.md +99 -0
  444. package/content/small-business/skills/small-business-smb-onboard/reference/website-research.md +82 -0
  445. package/content/small-business/skills/small-business-smb-router/SKILL.md +216 -0
  446. package/content/small-business/skills/small-business-smb-router/reference/connector-map.md +96 -0
  447. package/content/small-business/skills/small-business-social-content-engine/SKILL.md +162 -0
  448. package/content/small-business/skills/small-business-social-content-engine/reference/calendar.md +116 -0
  449. package/content/small-business/skills/small-business-social-content-engine/reference/canva-api.md +208 -0
  450. package/content/small-business/skills/small-business-social-content-engine/reference/examples/okonkwo-campaign.md +190 -0
  451. package/content/small-business/skills/small-business-social-content-engine/reference/gotchas.md +447 -0
  452. package/content/small-business/skills/small-business-social-content-engine/reference/publishing.md +166 -0
  453. package/content/small-business/skills/small-business-social-content-engine/reference/shopify-assets.md +77 -0
  454. package/content/small-business/skills/small-business-speed-to-lead/SKILL.md +172 -0
  455. package/content/small-business/skills/small-business-speed-to-lead/reference/approval.md +61 -0
  456. package/content/small-business/skills/small-business-speed-to-lead/reference/gotchas.md +167 -0
  457. package/content/small-business/skills/small-business-speed-to-lead/reference/qualification.md +153 -0
  458. package/content/small-business/skills/small-business-speed-to-lead/reference/response_patterns.md +184 -0
  459. package/content/small-business/skills/small-business-tax-prep/SKILL.md +85 -0
  460. package/content/small-business/skills/small-business-tax-season-organizer/SKILL.md +210 -0
  461. package/content/small-business/skills/small-business-tax-season-organizer/reference/calculation-assumptions.md +177 -0
  462. package/content/small-business/skills/small-business-tax-season-organizer/reference/connector-queries.md +267 -0
  463. package/content/small-business/skills/small-business-tax-season-organizer/reference/examples/quarterly-estimate.md +92 -0
  464. package/content/small-business/skills/small-business-tax-season-organizer/reference/examples/year-end-1099.md +102 -0
  465. package/content/small-business/skills/small-business-tax-season-organizer/reference/gotchas.md +104 -0
  466. package/content/small-business/skills/small-business-tax-season-organizer/reference/output-formats.md +68 -0
  467. package/content/small-business/skills/small-business-ticket-deflector/SKILL.md +164 -0
  468. package/content/small-business/skills/small-business-ticket-deflector/reference/examples/deny-refund-request.md +98 -0
  469. package/content/small-business/skills/small-business-ticket-deflector/reference/examples/respond-refund-request.md +77 -0
  470. package/content/small-business/skills/small-business-ticket-deflector/reference/gotchas.md +57 -0
  471. package/index.ts +83 -0
  472. package/package.json +28 -3
@@ -0,0 +1,290 @@
1
+ """
2
+ Sample name and metadata inference from filenames.
3
+
4
+ This module extracts sample information, detects tumor/normal status,
5
+ and matches R1/R2 read pairs from sequencing file names.
6
+ """
7
+
8
+ import os
9
+ import re
10
+ from typing import Dict, List, Optional, Tuple
11
+
12
+
13
+ # R1/R2 patterns with priority scores (higher = more confident)
14
+ R1_PATTERNS = [
15
+ (r'_R1_\d{3}', 10), # _R1_001 (Illumina standard)
16
+ (r'_R1[_.]', 8), # _R1. or _R1_
17
+ (r'\.R1[_.]', 8), # .R1. or .R1_
18
+ (r'_1[_.]', 5), # _1. or _1_
19
+ (r'_R1\.f', 6), # _R1.fastq
20
+ (r'_1\.f', 4), # _1.fastq
21
+ ]
22
+
23
+ R2_PATTERNS = [
24
+ (r'_R2_\d{3}', 10), # _R2_001 (Illumina standard)
25
+ (r'_R2[_.]', 8), # _R2. or _R2_
26
+ (r'\.R2[_.]', 8), # .R2. or .R2_
27
+ (r'_2[_.]', 5), # _2. or _2_
28
+ (r'_R2\.f', 6), # _R2.fastq
29
+ (r'_2\.f', 4), # _2.fastq
30
+ ]
31
+
32
+ # Tumor/normal keywords
33
+ TUMOR_KEYWORDS = [
34
+ r'\btumou?r\b',
35
+ r'\bmetastasis\b',
36
+ r'\bmet\b',
37
+ r'\bprimary\b',
38
+ r'\bcancer\b',
39
+ r'\bmalignant\b',
40
+ r'[-_]T[-_]',
41
+ r'[-_]T\d*$',
42
+ r'^T\d*[-_]',
43
+ ]
44
+
45
+ NORMAL_KEYWORDS = [
46
+ r'\bnormal\b',
47
+ r'\bgermline\b',
48
+ r'\bblood\b',
49
+ r'\bpbmc\b',
50
+ r'\bcontrol\b',
51
+ r'\bhealthy\b',
52
+ r'\bmatched\b',
53
+ r'[-_]N[-_]',
54
+ r'[-_]N\d*$',
55
+ r'^N\d*[-_]',
56
+ ]
57
+
58
+ # Lane pattern
59
+ LANE_PATTERN = r'[_.]L(\d{3})[_.]'
60
+
61
+ # Patient/sample extraction patterns
62
+ PATIENT_PATTERNS = [
63
+ r'^(P\d+)[-_]', # P001_sample
64
+ r'^(patient\d+)[-_]', # patient1_sample
65
+ r'^(TCGA-\w+-\w+)', # TCGA format
66
+ r'^([A-Z]{2,3}\d{3,})[-_]', # AB123_sample
67
+ ]
68
+
69
+ # Replicate patterns
70
+ REPLICATE_PATTERNS = [
71
+ r'[_.]rep(\d+)', # _rep1, .rep2
72
+ r'[_.]replicate(\d+)', # _replicate1
73
+ r'[_.]R(\d+)[_.]', # _R1_ (but not R1/R2 for reads!)
74
+ r'[-_](\d+)$', # sample_1 (last resort)
75
+ ]
76
+
77
+
78
+ def extract_sample_info(filepath: str) -> Dict[str, str]:
79
+ """
80
+ Extract sample metadata from filepath.
81
+
82
+ Args:
83
+ filepath: Path to sequencing file
84
+
85
+ Returns:
86
+ Dict with: sample, patient, lane (if detectable)
87
+ """
88
+ filename = os.path.basename(filepath)
89
+
90
+ # Remove extensions
91
+ stem = filename
92
+ for ext in ['.fastq.gz', '.fq.gz', '.fastq', '.fq', '.bam', '.cram', '.bai', '.crai']:
93
+ if stem.lower().endswith(ext):
94
+ stem = stem[:-len(ext)]
95
+ break
96
+
97
+ info = {}
98
+
99
+ # Extract lane
100
+ lane_match = re.search(LANE_PATTERN, stem)
101
+ info['lane'] = f"L{lane_match.group(1)}" if lane_match else "L001"
102
+
103
+ # Remove lane from stem
104
+ clean_stem = re.sub(LANE_PATTERN, '_', stem)
105
+
106
+ # Remove R1/R2 indicators and everything after
107
+ for pattern, _ in R1_PATTERNS + R2_PATTERNS:
108
+ clean_stem = re.sub(pattern + r'.*', '', clean_stem, flags=re.IGNORECASE)
109
+
110
+ # Clean up trailing/multiple underscores and dots
111
+ clean_stem = re.sub(r'[_.-]+$', '', clean_stem)
112
+ clean_stem = re.sub(r'[_.-]{2,}', '_', clean_stem)
113
+
114
+ # Try to extract patient ID
115
+ for pattern in PATIENT_PATTERNS:
116
+ match = re.match(pattern, clean_stem, re.IGNORECASE)
117
+ if match:
118
+ info['patient'] = match.group(1)
119
+ break
120
+
121
+ # Sample is the cleaned stem
122
+ info['sample'] = clean_stem if clean_stem else filename.split('.')[0]
123
+
124
+ # Default patient to sample if not extracted
125
+ if 'patient' not in info:
126
+ info['patient'] = info['sample']
127
+
128
+ return info
129
+
130
+
131
+ def infer_tumor_normal_status(sample_name: str) -> Optional[int]:
132
+ """
133
+ Infer tumor (1) or normal (0) status from sample name.
134
+
135
+ Args:
136
+ sample_name: Sample identifier
137
+
138
+ Returns:
139
+ 1 for tumor, 0 for normal, None if cannot determine
140
+ """
141
+ name_lower = sample_name.lower()
142
+
143
+ # Check tumor indicators
144
+ for pattern in TUMOR_KEYWORDS:
145
+ if re.search(pattern, name_lower, re.IGNORECASE):
146
+ return 1
147
+
148
+ # Check normal indicators
149
+ for pattern in NORMAL_KEYWORDS:
150
+ if re.search(pattern, name_lower, re.IGNORECASE):
151
+ return 0
152
+
153
+ return None
154
+
155
+
156
+ def extract_replicate_number(sample_name: str) -> Optional[int]:
157
+ """
158
+ Extract replicate number from sample name.
159
+
160
+ Args:
161
+ sample_name: Sample identifier
162
+
163
+ Returns:
164
+ Replicate number if found, None otherwise
165
+ """
166
+ for pattern in REPLICATE_PATTERNS:
167
+ match = re.search(pattern, sample_name, re.IGNORECASE)
168
+ if match:
169
+ try:
170
+ return int(match.group(1))
171
+ except ValueError:
172
+ continue
173
+ return None
174
+
175
+
176
+ def _get_pattern_score(filename: str, patterns: List[Tuple[str, int]]) -> int:
177
+ """Get highest matching pattern score."""
178
+ max_score = 0
179
+ for pattern, score in patterns:
180
+ if re.search(pattern, filename, re.IGNORECASE):
181
+ max_score = max(max_score, score)
182
+ return max_score
183
+
184
+
185
+ def _get_sample_key(filepath: str) -> str:
186
+ """Generate a key for grouping related files."""
187
+ info = extract_sample_info(filepath)
188
+ sample = info['sample']
189
+ lane = info.get('lane', 'L001')
190
+
191
+ # Include lane in key for multi-lane samples
192
+ if lane != "L001":
193
+ return f"{sample}_{lane}"
194
+ return sample
195
+
196
+
197
+ def match_read_pairs(files) -> Dict[str, Dict]:
198
+ """
199
+ Match R1/R2 read pairs using scored pattern matching.
200
+
201
+ Args:
202
+ files: List of FileInfo objects (from file_discovery)
203
+
204
+ Returns:
205
+ Dict mapping sample_key to {'r1': path, 'r2': path, 'info': dict}
206
+ """
207
+ # Classify files
208
+ r1_files = []
209
+ r2_files = []
210
+
211
+ for file in files:
212
+ filename = file.name if hasattr(file, 'name') else os.path.basename(str(file))
213
+ filepath = file.path if hasattr(file, 'path') else str(file)
214
+
215
+ r1_score = _get_pattern_score(filename, R1_PATTERNS)
216
+ r2_score = _get_pattern_score(filename, R2_PATTERNS)
217
+
218
+ if r2_score > r1_score and r2_score > 0:
219
+ r2_files.append((filepath, r2_score))
220
+ elif r1_score > 0:
221
+ r1_files.append((filepath, r1_score))
222
+ else:
223
+ # No clear indicator - assume R1 (single-end or non-standard naming)
224
+ r1_files.append((filepath, 0))
225
+
226
+ # Build pairs by matching sample keys
227
+ pairs = {}
228
+
229
+ # Process R1 files first
230
+ for r1_path, score in r1_files:
231
+ key = _get_sample_key(r1_path)
232
+ info = extract_sample_info(r1_path)
233
+
234
+ if key not in pairs:
235
+ pairs[key] = {
236
+ 'r1': r1_path,
237
+ 'r2': None,
238
+ 'info': info,
239
+ 'score': score
240
+ }
241
+ else:
242
+ # Multiple R1 files for same sample (should not happen)
243
+ pairs[key]['r1'] = r1_path
244
+
245
+ # Match R2 files
246
+ for r2_path, score in r2_files:
247
+ key = _get_sample_key(r2_path)
248
+ info = extract_sample_info(r2_path)
249
+
250
+ if key in pairs:
251
+ pairs[key]['r2'] = r2_path
252
+ else:
253
+ # R2 without matching R1
254
+ pairs[key] = {
255
+ 'r1': None,
256
+ 'r2': r2_path,
257
+ 'info': info,
258
+ 'score': score
259
+ }
260
+
261
+ return pairs
262
+
263
+
264
+ def infer_patient_groupings(sample_names: List[str]) -> Dict[str, str]:
265
+ """
266
+ Infer patient groupings from sample names.
267
+
268
+ Groups samples that share a common prefix pattern.
269
+
270
+ Args:
271
+ sample_names: List of sample identifiers
272
+
273
+ Returns:
274
+ Dict mapping sample_name to patient_id
275
+ """
276
+ patient_map = {}
277
+
278
+ for sample in sample_names:
279
+ # Try to find a patient pattern
280
+ for pattern in PATIENT_PATTERNS:
281
+ match = re.match(pattern, sample, re.IGNORECASE)
282
+ if match:
283
+ patient_map[sample] = match.group(1)
284
+ break
285
+
286
+ if sample not in patient_map:
287
+ # Default: each sample is its own patient
288
+ patient_map[sample] = sample
289
+
290
+ return patient_map
@@ -0,0 +1,256 @@
1
+ """
2
+ Samplesheet validation utilities.
3
+
4
+ Validates samplesheet rows against pipeline configuration before writing,
5
+ catching errors early with helpful messages.
6
+ """
7
+
8
+ import os
9
+ from dataclasses import dataclass, field
10
+ from pathlib import Path
11
+ from typing import Dict, List, Optional
12
+ import yaml
13
+
14
+
15
+ @dataclass
16
+ class ValidationResult:
17
+ """Result of samplesheet validation."""
18
+ valid: bool
19
+ errors: List[str] = field(default_factory=list)
20
+ warnings: List[str] = field(default_factory=list)
21
+ suggestions: List[str] = field(default_factory=list)
22
+
23
+ def __bool__(self):
24
+ return self.valid
25
+
26
+ def summary(self) -> str:
27
+ """Generate human-readable summary."""
28
+ lines = []
29
+ if self.errors:
30
+ lines.append("Errors:")
31
+ for e in self.errors:
32
+ lines.append(f" - {e}")
33
+ if self.warnings:
34
+ lines.append("Warnings:")
35
+ for w in self.warnings:
36
+ lines.append(f" - {w}")
37
+ if self.suggestions:
38
+ lines.append("Suggestions:")
39
+ for s in self.suggestions:
40
+ lines.append(f" - {s}")
41
+ return "\n".join(lines)
42
+
43
+
44
+ def load_pipeline_config(pipeline: str) -> Optional[Dict]:
45
+ """Load pipeline configuration from YAML file."""
46
+ # Find config directory relative to this file
47
+ script_dir = Path(__file__).parent.parent.parent
48
+ config_path = script_dir / "config" / "pipelines" / f"{pipeline}.yaml"
49
+
50
+ if not config_path.exists():
51
+ return None
52
+
53
+ with open(config_path) as f:
54
+ return yaml.safe_load(f)
55
+
56
+
57
+ def validate_samplesheet(
58
+ rows: List[Dict],
59
+ pipeline: str,
60
+ config: Optional[Dict] = None
61
+ ) -> ValidationResult:
62
+ """
63
+ Validate samplesheet rows against pipeline requirements.
64
+
65
+ Args:
66
+ rows: List of row dictionaries
67
+ pipeline: Pipeline name (e.g., 'rnaseq', 'sarek')
68
+ config: Optional pre-loaded config dict
69
+
70
+ Returns:
71
+ ValidationResult with errors, warnings, and suggestions
72
+ """
73
+ errors = []
74
+ warnings = []
75
+ suggestions = []
76
+
77
+ # Load config if not provided
78
+ if config is None:
79
+ config = load_pipeline_config(pipeline)
80
+
81
+ if config is None:
82
+ errors.append(f"Unknown pipeline: {pipeline}")
83
+ return ValidationResult(valid=False, errors=errors)
84
+
85
+ columns = config.get("samplesheet", {}).get("columns", [])
86
+ required_cols = [c["name"] for c in columns if c.get("required", False)]
87
+
88
+ if not rows:
89
+ errors.append("Samplesheet is empty - no samples found")
90
+ return ValidationResult(valid=False, errors=errors)
91
+
92
+ # Validate each row
93
+ for i, row in enumerate(rows):
94
+ row_num = i + 2 # Account for header row
95
+
96
+ # Check required columns
97
+ for col_name in required_cols:
98
+ col_config = next((c for c in columns if c["name"] == col_name), None)
99
+
100
+ # Skip columns with conditions that don't apply
101
+ if col_config and "condition" in col_config:
102
+ # Simple condition check - skip for now
103
+ # Full implementation would evaluate conditions
104
+ pass
105
+
106
+ if col_name not in row or row[col_name] is None or row[col_name] == "":
107
+ # Check if there's a default
108
+ if col_config and "default" in col_config:
109
+ continue
110
+ errors.append(f"Row {row_num}: Missing required column '{col_name}'")
111
+
112
+ # Validate path columns exist
113
+ for col_name in ["fastq_1", "fastq_2", "bam", "bai"]:
114
+ if col_name in row and row[col_name]:
115
+ path = row[col_name]
116
+ if not os.path.exists(path):
117
+ errors.append(f"Row {row_num}: File not found: {path}")
118
+ elif not os.path.isfile(path):
119
+ errors.append(f"Row {row_num}: Not a file: {path}")
120
+
121
+ # Validate enum values
122
+ for col_config in columns:
123
+ col_name = col_config["name"]
124
+ if col_name in row and row[col_name] and "allowed" in col_config:
125
+ value = row[col_name]
126
+ allowed = col_config["allowed"]
127
+ if value not in allowed:
128
+ errors.append(
129
+ f"Row {row_num}: Invalid value '{value}' for '{col_name}'. "
130
+ f"Allowed: {allowed}"
131
+ )
132
+
133
+ # Check R1/R2 pairing consistency
134
+ r1 = row.get("fastq_1", "")
135
+ r2 = row.get("fastq_2", "")
136
+ if r1 and not r2:
137
+ warnings.append(f"Row {row_num}: Single-end data (no R2 file)")
138
+ elif r2 and not r1:
139
+ errors.append(f"Row {row_num}: R2 present but R1 missing")
140
+
141
+ # Check for duplicate samples
142
+ sample_col = "sample" if "sample" in rows[0] else "patient"
143
+ if sample_col in rows[0]:
144
+ samples = [r.get(sample_col, "") for r in rows]
145
+ duplicates = [s for s in set(samples) if samples.count(s) > 1]
146
+ if duplicates:
147
+ warnings.append(f"Duplicate sample names: {duplicates}")
148
+ suggestions.append(
149
+ "Duplicates may be intentional (multi-lane sequencing). "
150
+ "Verify sample grouping is correct."
151
+ )
152
+
153
+ # Pipeline-specific validation
154
+ if pipeline == "sarek":
155
+ _validate_sarek_specific(rows, errors, warnings, suggestions)
156
+ elif pipeline == "atacseq":
157
+ _validate_atacseq_specific(rows, errors, warnings, suggestions)
158
+
159
+ return ValidationResult(
160
+ valid=len(errors) == 0,
161
+ errors=errors,
162
+ warnings=warnings,
163
+ suggestions=suggestions
164
+ )
165
+
166
+
167
+ def _validate_sarek_specific(
168
+ rows: List[Dict],
169
+ errors: List[str],
170
+ warnings: List[str],
171
+ suggestions: List[str]
172
+ ):
173
+ """Sarek-specific validation for tumor/normal pairing."""
174
+ # Group by patient
175
+ patients = {}
176
+ for row in rows:
177
+ patient = row.get("patient", "")
178
+ status = row.get("status")
179
+
180
+ if patient not in patients:
181
+ patients[patient] = {"tumor": 0, "normal": 0, "unknown": 0}
182
+
183
+ if status == 1:
184
+ patients[patient]["tumor"] += 1
185
+ elif status == 0:
186
+ patients[patient]["normal"] += 1
187
+ else:
188
+ patients[patient]["unknown"] += 1
189
+
190
+ # Check pairing
191
+ for patient, counts in patients.items():
192
+ if counts["tumor"] > 0 and counts["normal"] == 0:
193
+ warnings.append(
194
+ f"Patient '{patient}': Tumor sample(s) without matched normal. "
195
+ "Somatic calling works best with paired tumor-normal."
196
+ )
197
+ suggestions.append(
198
+ f"For patient '{patient}': Add a normal sample or use tumor-only mode."
199
+ )
200
+
201
+ if counts["unknown"] > 0:
202
+ warnings.append(
203
+ f"Patient '{patient}': {counts['unknown']} sample(s) with unknown status. "
204
+ "Set status column to 0 (normal) or 1 (tumor)."
205
+ )
206
+
207
+
208
+ def _validate_atacseq_specific(
209
+ rows: List[Dict],
210
+ errors: List[str],
211
+ warnings: List[str],
212
+ suggestions: List[str]
213
+ ):
214
+ """ATAC-seq specific validation for replicates."""
215
+ # Group by sample (condition)
216
+ samples = {}
217
+ for row in rows:
218
+ sample = row.get("sample", "")
219
+ replicate = row.get("replicate", 1)
220
+
221
+ if sample not in samples:
222
+ samples[sample] = []
223
+
224
+ samples[sample].append(replicate)
225
+
226
+ # Check replicates
227
+ for sample, reps in samples.items():
228
+ if len(reps) < 2:
229
+ warnings.append(
230
+ f"Sample '{sample}': Only {len(reps)} replicate(s). "
231
+ "Consensus peaks require 2+ replicates."
232
+ )
233
+
234
+ # Check for duplicate replicate numbers
235
+ if len(reps) != len(set(reps)):
236
+ errors.append(
237
+ f"Sample '{sample}': Duplicate replicate numbers detected. "
238
+ "Each replicate must have a unique number."
239
+ )
240
+
241
+ # Check all samples have R2 (ATAC-seq requires paired-end)
242
+ for i, row in enumerate(rows):
243
+ if not row.get("fastq_2"):
244
+ errors.append(
245
+ f"Row {i+2}: ATAC-seq requires paired-end data. R2 file missing."
246
+ )
247
+
248
+
249
+ def validate_file_exists(path: str) -> bool:
250
+ """Check if file exists and is accessible."""
251
+ return os.path.isfile(path) and os.access(path, os.R_OK)
252
+
253
+
254
+ def validate_absolute_path(path: str) -> bool:
255
+ """Check if path is absolute."""
256
+ return os.path.isabs(path)