NextPyper 0.1.0__py3-none-any.whl

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 (69) hide show
  1. nextpyper/__init__.py +0 -0
  2. nextpyper/__main__.py +429 -0
  3. nextpyper/config/config.yaml +80 -0
  4. nextpyper/config/rich_config.yaml +54 -0
  5. nextpyper/config/system_config.yaml +10 -0
  6. nextpyper/data/blosum62.csv +32 -0
  7. nextpyper/data/cps_seqids.csv +674 -0
  8. nextpyper/data/mock/mock_args.yaml +17 -0
  9. nextpyper/data/mock/probes.fasta +56 -0
  10. nextpyper/data/mock/reads/sample1_R1.fastq +20 -0
  11. nextpyper/data/mock/reads/sample1_R2.fastq +20 -0
  12. nextpyper/data/mock/reads/sample2_R1.fastq +20 -0
  13. nextpyper/data/mock/reads/sample2_R2.fastq +20 -0
  14. nextpyper/data/mock/reads/sample3_R1.fastq +20 -0
  15. nextpyper/data/mock/reads/sample3_R2.fastq +20 -0
  16. nextpyper/data/mock/sample.tsv +4 -0
  17. nextpyper/nextpyper.CITATION +9 -0
  18. nextpyper/nextpyper.LICENSE +19 -0
  19. nextpyper/nextpyper.VERSION +1 -0
  20. nextpyper/src/divergence_estimation.py +131 -0
  21. nextpyper/src/diversity.py +93 -0
  22. nextpyper/src/exon_discovery.py +294 -0
  23. nextpyper/src/exon_intron.py +197 -0
  24. nextpyper/src/fix_headers.py +107 -0
  25. nextpyper/src/gfa2fasta.py +71 -0
  26. nextpyper/src/gfa_graph.py +1245 -0
  27. nextpyper/src/gff_parser.py +344 -0
  28. nextpyper/src/graph_utils.py +201 -0
  29. nextpyper/src/homolog_filtering.py +411 -0
  30. nextpyper/src/miniprot.py +1008 -0
  31. nextpyper/src/multi_seq_probes.py +292 -0
  32. nextpyper/src/run_orfipy.py +493 -0
  33. nextpyper/src/sample_table.py +63 -0
  34. nextpyper/src/seeds_collection.py +387 -0
  35. nextpyper/src/summarize_results.py +507 -0
  36. nextpyper/src/union_find.py +65 -0
  37. nextpyper/src/var_asm_parser.py +229 -0
  38. nextpyper/test/.gitkeep +0 -0
  39. nextpyper/workflow/Snakefile +62 -0
  40. nextpyper/workflow/envs/alignment.yaml +7 -0
  41. nextpyper/workflow/envs/assembly.yaml +8 -0
  42. nextpyper/workflow/envs/clustering.yaml +9 -0
  43. nextpyper/workflow/envs/matching.yaml +8 -0
  44. nextpyper/workflow/envs/preprocessing.yaml +11 -0
  45. nextpyper/workflow/envs/saute.yaml +7 -0
  46. nextpyper/workflow/envs/translating.yaml +8 -0
  47. nextpyper/workflow/rules/0_preprocessing/0.1_reads.smk +90 -0
  48. nextpyper/workflow/rules/0_preprocessing/0.2_probes.smk +16 -0
  49. nextpyper/workflow/rules/1_seeds_assembly/1.1_assembly_spades.smk +48 -0
  50. nextpyper/workflow/rules/1_seeds_assembly/1.2_seeds_extension.smk +90 -0
  51. nextpyper/workflow/rules/1_seeds_assembly/1.3_seeds_filtering.smk +64 -0
  52. nextpyper/workflow/rules/1_seeds_assembly/1.4_seeds_clustering.smk +73 -0
  53. nextpyper/workflow/rules/2_homologs_assembly/2.1_saute_assembly.smk +228 -0
  54. nextpyper/workflow/rules/3_homolog_prospection/3.1_allele_collapsing.smk +23 -0
  55. nextpyper/workflow/rules/3_homolog_prospection/3.2_homologs_filtering.smk +76 -0
  56. nextpyper/workflow/rules/3_homolog_prospection/3.3_region_separation.smk +189 -0
  57. nextpyper/workflow/rules/common.smk +160 -0
  58. nextpyper/workflow/schemas/probes.yaml +12 -0
  59. nextpyper/workflow/schemas/sample_table.yaml +29 -0
  60. nextpyper/workflow/scripts/bench_busco.py +572 -0
  61. nextpyper/workflow/scripts/categories_bench.sh +92 -0
  62. nextpyper/workflow/scripts/end_recs_parser.py +146 -0
  63. nextpyper/workflow/scripts/tribble_stats.py +131 -0
  64. nextpyper-0.1.0.dist-info/METADATA +231 -0
  65. nextpyper-0.1.0.dist-info/RECORD +69 -0
  66. nextpyper-0.1.0.dist-info/WHEEL +5 -0
  67. nextpyper-0.1.0.dist-info/entry_points.txt +3 -0
  68. nextpyper-0.1.0.dist-info/licenses/nextpyper/nextpyper.LICENSE +19 -0
  69. nextpyper-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,146 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from collections import defaultdict
4
+ import re
5
+
6
+ from Bio import SeqIO
7
+
8
+ """This script parses the final output of different pipelines (NextPyper, Captus, HybPiper) to restructure
9
+ the results from being organized per probe to being organized per sample."""
10
+
11
+
12
+ CAPTUS_HEADER = r"\[query=(.*)\]\s\[hit=(\d+)\]"
13
+
14
+
15
+ def parse_nextpyper(results_path: Path, parsed_dir: Path, kind: str = "supercontigs"):
16
+ """
17
+ Parse the end recs from the NextPyper results_path (separation_output folder) structured
18
+ per probe, restructure them per sample and save them in parsed_dir, in a file per sample.
19
+ """
20
+
21
+ parsed_dir.mkdir(parents=True, exist_ok=True)
22
+ if not results_path.exists():
23
+ raise FileNotFoundError(f"Results path {results_path} does not exist.")
24
+ if not results_path.is_dir():
25
+ raise NotADirectoryError(f"Results path {results_path} is not a directory.")
26
+
27
+ sample_recs = defaultdict(list)
28
+ for file in results_path.rglob(f"*{kind}.fasta"):
29
+ for rec in SeqIO.parse(file, "fasta"):
30
+ sample = rec.id.split("|")[0]
31
+ sample_recs[sample].append(rec)
32
+
33
+ for sample, recs in sample_recs.items():
34
+ SeqIO.write(recs, parsed_dir / f"{sample}.fasta", "fasta")
35
+
36
+
37
+ def parse_captus(results_path: Path, parsed_dir: Path):
38
+ """
39
+ Parse the end recs from the captus results_path structured per probe,
40
+ restructure them per sample and save them in parsed_dir, in a file per sample.
41
+ Sequences are uppercased and dashes are removed.
42
+
43
+ The probe and hit fields in the description are added as a suffix to the sequence
44
+ name to eliminate name duplicates.
45
+ """
46
+
47
+ head_pat = re.compile(CAPTUS_HEADER)
48
+
49
+ sample_recs = defaultdict(list)
50
+ for file in results_path.glob("*.fna"):
51
+ for rec in SeqIO.parse(file, "fasta"):
52
+ sample = rec.id.split("__")[0]
53
+ rec.description = rec.description.removeprefix(f"{rec.id} ")
54
+ match = head_pat.search(rec.description)
55
+ rec.id = rec.name = f"{rec.id}|{match.group(1)}_hit{match.group(2)}"
56
+ rec.seq = rec.seq.upper().replace("-", "")
57
+ sample_recs[sample].append(rec)
58
+
59
+ for sample, recs in sample_recs.items():
60
+ SeqIO.write(recs, parsed_dir / f"{sample}.fasta", "fasta")
61
+
62
+
63
+ def parse_hybpiper(results_path: Path, parsed_dir: Path):
64
+ """
65
+ Parse the end recs from the HybPiper results_path where two folders are expected paralogs
66
+ and supercontigs, structured per probe. The sequences are restructured per sample. For a
67
+ given probe, if there are more sequences in the paralogs, the paralogs are used, otherwise
68
+ the supercontigs are used. The sequences are then saved in parsed_dir, in a file per sample.
69
+
70
+ The file name (expected to be the probe) is added as a suffix to the sequence name to
71
+ eliminate name duplicates.
72
+ """
73
+
74
+ sample_recs = defaultdict(list)
75
+ for sctg_path in (results_path / "supercontigs").glob("*.fasta"):
76
+ paralogs_path = results_path / f"paralogs/{sctg_path.stem}_paralogs_all.fasta"
77
+
78
+ sctg = list(SeqIO.parse(sctg_path, "fasta"))
79
+ paralogs = list(SeqIO.parse(paralogs_path, "fasta"))
80
+
81
+ recs = paralogs if len(paralogs) > len(sctg) else sctg
82
+ for rec in recs:
83
+ sample = rec.id.split(".")[0]
84
+ rec.id = rec.name = f"{rec.id}|{sctg_path.stem}"
85
+ rec.seq = rec.seq.upper().replace("-", "").replace("N", "")
86
+ sample_recs[sample].append(rec)
87
+
88
+ for sample, recs in sample_recs.items():
89
+ SeqIO.write(recs, parsed_dir / f"{sample}.fasta", "fasta")
90
+
91
+
92
+ def parse_args():
93
+ parser = argparse.ArgumentParser(
94
+ description="Parse NextPyper final output structure from per probe to per sample."
95
+ )
96
+ parser.add_argument(
97
+ "pipeline_results", type=Path, help="Path to per probe sequence output."
98
+ )
99
+ parser.add_argument(
100
+ "output_folder", type=Path, help="Path where to write the parsed results."
101
+ )
102
+ parser.add_argument(
103
+ "pipeline",
104
+ type=str,
105
+ choices=["nextpyper", "captus", "hybpiper"],
106
+ help="Pipelined used (affects the expected file structure).",
107
+ )
108
+
109
+ parser.add_argument(
110
+ "-k",
111
+ "--kind",
112
+ type=str,
113
+ default="supercontigs",
114
+ choices=["supercontigs", "genotigs", "exons"],
115
+ help="For NextPyper, which kind of sequences to retrieve.",
116
+ )
117
+ return parser.parse_args()
118
+
119
+
120
+ def main():
121
+ args = parse_args()
122
+ args.output_folder.mkdir(parents=True, exist_ok=True)
123
+ if not args.pipeline_results.exists():
124
+ raise FileNotFoundError(f"Results path {args.pipeline_results} does not exist.")
125
+ if not args.pipeline_results.is_dir():
126
+ raise NotADirectoryError(
127
+ f"Results path {args.pipeline_results} is not a directory."
128
+ )
129
+ if not args.output_folder.is_dir():
130
+ raise NotADirectoryError(
131
+ f"Parsed directory {args.output_folder} is not a directory."
132
+ )
133
+
134
+ match args.pipeline:
135
+ case "nextpyper":
136
+ parse_nextpyper(args.pipeline_results, args.output_folder, args.kind)
137
+ case "captus":
138
+ parse_captus(args.pipeline_results, args.output_folder)
139
+ case "hybpiper":
140
+ parse_hybpiper(args.pipeline_results, args.output_folder)
141
+ case _:
142
+ raise ValueError(f"Unknown pipeline: {args.pipeline}")
143
+
144
+
145
+ if __name__ == "__main__":
146
+ main()
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ #
5
+ # Copyright (C) 2024
6
+ # Simón Villanueva CORRALES: simon.corrales@ibot.cas.cz
7
+ # Yann J.K. BERTRAND: yjk_bertrand@ybertrand.org
8
+ #
9
+ # All rights reserved.
10
+
11
+ """Basic tribbles' stats computation in a nextpyper run."""
12
+
13
+ # =======================================================================================
14
+ # IMPORTS
15
+ # =======================================================================================
16
+
17
+ from pathlib import Path
18
+ import argparse
19
+ import yaml
20
+ import sys
21
+
22
+ import dpath
23
+ from Bio import SeqIO
24
+ import polars as pl
25
+
26
+ sys.path.append(str((Path(__file__) / "../../../src").resolve()))
27
+
28
+ from var_asm_parser import collapse_alleles_df, collapse_variants_df, query2df
29
+
30
+ # =============================================================================
31
+ # CONSTANTS
32
+ # =============================================================================
33
+
34
+ from var_asm_parser import TARGET_PAT, FIELDS
35
+
36
+ TRIBBLE_LIM_DPATH = "nextpyper/pipeline/saute/reassembly/explosive_limit"
37
+ NEW_TRIBBLE_LIM_DPATH = "nextpyper/pipeline/saute/max_variants"
38
+
39
+ # =============================================================================
40
+ # FUNCTIONS
41
+ # =============================================================================
42
+
43
+
44
+ def read_target_vars(
45
+ vars: Path, tribble_lim: int, header_pat: str = TARGET_PAT
46
+ ) -> pl.DataFrame:
47
+ df = query2df(SeqIO.parse(vars, "fasta"), header_pat, FIELDS)
48
+ return (
49
+ collapse_variants_df(collapse_alleles_df(df))
50
+ .with_columns(pl.col("probe").cast(pl.String))
51
+ .filter(pl.col("var_count") > tribble_lim)
52
+ .group_by("probe")
53
+ .agg(tribble=pl.len())
54
+ )
55
+
56
+
57
+ def find_tribbles(run_dir: Path, sample: str, tribble_lim: int = 30) -> pl.DataFrame:
58
+ """Compute the tribbles for a single sample"""
59
+
60
+ before_vars = run_dir / f"saute/target_assembly/{sample}/target_vars.fasta"
61
+ after_vars = run_dir / f"saute/final/collected/{sample}.fasta"
62
+
63
+ tribble_df = read_target_vars(before_vars, tribble_lim)
64
+
65
+ if after_vars.exists():
66
+ tribble_df2 = read_target_vars(after_vars, tribble_lim)
67
+ merged = tribble_df.join(tribble_df2, on="probe", how="left", suffix="_2nd")
68
+ merged = merged.select(
69
+ pl.col("probe").len(),
70
+ pl.sum("tribble"),
71
+ (pl.col("tribble_2nd") > 0).sum().alias("probe_2nd"),
72
+ pl.sum("tribble_2nd"),
73
+ )
74
+ else:
75
+ merged = tribble_df.select(
76
+ pl.col("probe").len(), pl.sum("tribble")
77
+ ).with_columns(probe_2nd=None, tribble_2nd=None)
78
+
79
+ return merged.insert_column(0, pl.lit(sample).alias("sample"))
80
+
81
+
82
+ def summarize_tribbles(run_dir: Path, tribble_lim: int | None = None) -> None:
83
+ """Compute and summarize tribble stats for a whole run. Print the results table to stdout.
84
+ The table includes the counts of probes with tribbles, and number of tribbles for both
85
+ the first assembly and second assembly (secondary)."""
86
+
87
+ with (run_dir / "config.yaml").open() as file:
88
+ config = yaml.load(file, yaml.BaseLoader)
89
+ try:
90
+ reasm = dpath.get(config, "nextpyper/args/reasm")
91
+ except KeyError:
92
+ reasm = True
93
+
94
+ if tribble_lim is None:
95
+ try:
96
+ tribble_lim = int(dpath.get(config, TRIBBLE_LIM_DPATH))
97
+ except KeyError:
98
+ tribble_lim = int(dpath.get(config, NEW_TRIBBLE_LIM_DPATH))
99
+
100
+ df = pl.concat(
101
+ find_tribbles(run_dir, sample.stem, tribble_lim)
102
+ for sample in (run_dir / "saute/target_assembly").iterdir()
103
+ )
104
+
105
+ print(f"# {tribble_lim=}, {reasm=}")
106
+ df.sort("sample").write_csv(sys.stdout, separator="\t", null_value="null")
107
+
108
+
109
+ def parse_args():
110
+ parser = argparse.ArgumentParser(
111
+ description="Compute tribble stats of a NextPyper run to stdout as a tsv"
112
+ )
113
+ parser.add_argument("rundir", type=Path, help="Path to rundir")
114
+ parser.add_argument(
115
+ "-t",
116
+ "--tribble-lim",
117
+ type=int,
118
+ default=None,
119
+ help="""Maximum number of variants in a component to consider it a tribble. By default,
120
+ read the limit used in the run.""",
121
+ )
122
+ return parser.parse_args()
123
+
124
+
125
+ def main():
126
+ args = parse_args()
127
+ summarize_tribbles(args.rundir, args.tribble_lim)
128
+
129
+
130
+ if __name__ == "__main__":
131
+ main()
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: NextPyper
3
+ Version: 0.1.0
4
+ Summary: Recovery of homoeologous loci from target capture data in higher ploidy samples
5
+ Author-email: Simón Villanueva Corrales <simon.corrales@ibot.cas.cz>, "Yann J.K. Bertrand" <Yann.Bertrand@ibot.cas.cz>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/M2BL/NextPyper
8
+ Project-URL: Documentation, https://m2bl.github.io/NextPyper
9
+ Classifier: Environment :: Console
10
+ Classifier: Environment :: MacOS X
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Requires-Python: >=3.12
18
+ Description-Content-Type: text/markdown
19
+ License-File: nextpyper/nextpyper.LICENSE
20
+ Requires-Dist: snaketool-utils>=0.0.4
21
+ Requires-Dist: snakemake>=9.21
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: Click>=8.1.3
24
+ Requires-Dist: rich-click>=1.9.7
25
+ Requires-Dist: pandas>=2.2
26
+ Requires-Dist: biopython>=1.83
27
+ Requires-Dist: numpy>=1.26
28
+ Requires-Dist: scikit-learn>=1.5
29
+ Requires-Dist: scipy>=1.14
30
+ Requires-Dist: polars>=1.32.3
31
+ Requires-Dist: intervaltree>=3.1
32
+ Requires-Dist: kmedoids>=0.5.3.1
33
+ Requires-Dist: more-itertools>=10.7
34
+ Dynamic: license-file
35
+
36
+ # NextPyper
37
+ Recovery of homoeologous loci from target capture data in higher ploidy samples.
38
+
39
+ ## Documentation
40
+
41
+ Please refer to the [official documentation](https://m2bl.github.io/NextPyper/), which is more complete.
42
+
43
+ ## Table of contents
44
+
45
+ - [Installation](#installation)
46
+ - [Conda/Mamba](#condamamba)
47
+ - [Pip](#pip)
48
+ - [Manual](#manual)
49
+ - [Environments setup (recommended)](#environments-setup-recommended)
50
+ - [Usage](#usage)
51
+ - [1. Preparing your probes](#1-preparing-your-probes)
52
+ - [Single-probe sets](#single-probe-sets)
53
+ - [Multi-probe sets](#multi-probe-sets)
54
+ - [2. Preparing your samples](#2-preparing-your-samples)
55
+ - [3. Running NextPyper](#3-running-nextpyper)
56
+ - [Output](#output)
57
+ - [Sequence versions](#sequence-versions)
58
+ - [Output structure](#output-structure)
59
+
60
+
61
+ ## Installation
62
+
63
+ Regardless of the installation method, `NextPyper` requires `conda` in your PATH, to manage and deploy workflow environments.
64
+
65
+ ### Conda/Mamba
66
+
67
+ If you already have [bioconda](https://bioconda.github.io/) set up, you can create a new environment and simply run:
68
+
69
+ ```bash
70
+ conda install nextpyper # or mamba
71
+ ```
72
+
73
+ ### Pip
74
+
75
+ Alternatively you can use pip:
76
+
77
+ ```
78
+ pip install nextpyper
79
+ ```
80
+
81
+ ### Manual
82
+
83
+ You can also install NextPyper manually with pip. We recommend to create a new environment.
84
+
85
+ ```bash
86
+ # from your new environment with pip
87
+ git clone git@github.com:M2BL/NextPyper.git
88
+ cd NextPyper
89
+ pip install .
90
+ ```
91
+
92
+ ## Environments setup (recommended)
93
+
94
+ NextPyper uses [snakemake](https://snakemake.github.io/) to orchestrate and execute the different steps of the workflow, which uses conda to set up the packages and environments required at each stage.
95
+
96
+ The first time you run NextPyper, this setup will be done automatically at the start of the workflow.
97
+
98
+ Alternatively, you can set up these environments beforehand by running:
99
+
100
+ ```bash
101
+ nextpyper prepare
102
+ ```
103
+
104
+ This command creates the required environments within NextPyper's installation path. You can use the option `--conda-prefix` to specify a different path where to store these environments.
105
+
106
+ ## Usage
107
+
108
+ NextPyper requires two inputs, a probes file with the targets of your experiment, and a sample table describing where to find the data of your samples.
109
+
110
+ ### 1. Preparing your probes
111
+
112
+ NextPyper expects a nucleotide fasta file with the sequences of the targeted loci, what we call the probe set. Probe sets can be divided into two categories:
113
+
114
+ - **Multi probe sets**: Contains multiple sequences per locus/gene (*e.g.* Angiosperms353).
115
+ - **Single probe sets**: Contains a single sequence per locus. Usually, custom probe sets designed from a single reference genome fall in this category.
116
+
117
+ Sequence names in the probe set are required to be simple (letters, numbers and underscore, characters only). Additionally no duplicated names are allowed.
118
+
119
+ Currently, only coding regions that can be translated are supported.
120
+
121
+ #### Single-probe sets
122
+
123
+ If you are using a single-probe set, you only need to worry about sticking to the naming conventions described above. To check your probes, you can use `nextpyper validate`:
124
+
125
+ ```bash
126
+ $ nextpyper validate --probes probes.fasta
127
+
128
+ # Probe sequence names comply with naming convention.
129
+ # Pattern (.*) yielded no grouping of the sequences.
130
+ # Either this is a single-probe set or the pattern is not appropriate for multi-probe mode
131
+ ```
132
+
133
+ If you get the message above, your probe set is well formatted to run in single-probes mode.
134
+
135
+ #### Multi-probe sets
136
+
137
+ If using a multi-probe set, NextPyper needs to know which sequences target the same locus. The option `--pattern` expects a RegEx (with one capture group) that will inform about that hierarchy based on the name of the probes.
138
+
139
+ For instance, for the Angiosperms353 probe set with sequence names:
140
+
141
+ ```
142
+ AJFN_probe4471
143
+ Ambtr_probe4471
144
+ BERS_probe4527
145
+ ZENX_probe4527
146
+ Arath_probe4691
147
+ QUTB_probe4691
148
+ ```
149
+
150
+ We can use `--pattern "(\d+)$"`, which will group the sequences by the number at the end of the sequence name (which is the LocusID).
151
+
152
+ You can use the `validate` subcommand to check if your pattern groups your probes:
153
+
154
+ ```bash
155
+ $ nextpyper validate --probes kew_probes.fasta --pattern "(\d+)$"
156
+
157
+ # Probe sequence names comply with naming convention.
158
+ # The pattern yields 353 groups from 4781 probe sequences
159
+ ```
160
+
161
+ Use the options `--out_summary` and `--out_hierarchy` to get more details about the grouping.
162
+
163
+ ### 2. Preparing your samples
164
+
165
+ NextPyper expects a 4-column table that defines the identity and ploidy of your samples, and where to find their associated data.
166
+
167
+ Knowledge about your samples' ploidy is not required to run NextPyper. Simply set it to 0, if you do not know it, or do not want to take it into account.
168
+
169
+ The table requires a header with 4 columns (see an example here):
170
+
171
+ - sample: the name of the sample.
172
+ - path_forward: absolute path to the forward reads. It can be .gz compressed.
173
+ - path_reverse: absolute path to the reverse reads. It can be .gz compressed.
174
+ - ploidy: the ploidy of the sample. If 0, ploidy won't be taken into account to process the sample.
175
+
176
+ You can use the `gather` subcommand to help you create the sample table. From a data directory ([like this one](https://github.com/M2BL/NextPyper/tree/main/nextpyper/data/mock/reads)) with only the paired-end data (forward and reverse files) you can run:
177
+
178
+ ```bash
179
+ nextpyper gather --input data_folder --output sample.tsv
180
+ ```
181
+
182
+ To get the input the sample table for your samples. See an example of the result [here](https://github.com/M2BL/NextPyper/blob/main/nextpyper/data/mock/sample.tsv).
183
+
184
+ The sample names are inferred based on the common prefix between the forward and reverse files.
185
+
186
+ ### 3. Running NextPyper
187
+
188
+ Finally, use the `run` subcommand to start the workflow. For single-probes you do not need to specify a pattern, so simply provide the inputs we prepared:
189
+
190
+ ```bash
191
+ nextpyper run --threads 16 --single-probes --input input_samples.tsv --probes custom_probes.fasta --output out_single
192
+ ```
193
+
194
+ For multi-probes, specify the appropriate pattern as well:
195
+
196
+ ```bash
197
+ nextpyper run --threads 16 --input new_hier_samples.tsv --probes kew_probes.fasta --pattern "(\d+)$" --output out_multi
198
+ ```
199
+
200
+
201
+ ## Output
202
+
203
+ ### Sequence versions
204
+
205
+ The main output of NextPyper are the samples' homologous sequences for each targeted locus. We generate 3 versions of these sequences, depending on the final postprocessing:
206
+
207
+ - **Exons**: includes only the exonic part of the sequence.
208
+ - **Genetigs**: includes exons and introns.
209
+ - **Supercontigs**: The full sequence, including exons, introns and flanking regions.
210
+
211
+ The exons are the shorter and more conserved version of the output sequences, while the supercontigs are longer and include all discovered variation (which can be a bit noisy). Genetigs usually provide a good balance, containing more signal than the exons without it being overwhelming. You may want to explore which type of sequence suits better your purposes.
212
+
213
+ ### Output structure
214
+
215
+ NextPyper organizes its main outputs in the following fashion:
216
+
217
+ - Homologous sequences per sample: `<outdir>/outputs/seqs_per_sample`
218
+ - Homologous sequences per locus: `<outdir>/outputs/seqs_per_locus`
219
+ - Loci Multiple Sequence Alignments (MSAs): `<outdir>/outputs/alignments`
220
+
221
+ NextPyper output directory follows the following structure:
222
+
223
+ ```
224
+ outdir
225
+ ├── config.yaml # Final config with parameters used to run the workflow.
226
+ ├── execution.log # Snakemake execution log of all workflow jobs.
227
+ ├── logs/ # Logs generated by the workflow jobs.
228
+ ├── nextpyper.log # Summary of params and snakemake invocation.
229
+ ├── outputs/ # Final outputs of the workflow.
230
+ └── workflow/ # Working folder for all the jobs and stages of the pipeline. It contains intermediate and final files.
231
+ ```
@@ -0,0 +1,69 @@
1
+ nextpyper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ nextpyper/__main__.py,sha256=eYdlJtJ2-nd2sXeiISvRvGaZT7yu4GwHZeA8dnVpbZs,11884
3
+ nextpyper/nextpyper.CITATION,sha256=AJklL9scU8NWrOIBzk66WDRDPxJCUxB-Aby73-Rl7Ng,221
4
+ nextpyper/nextpyper.LICENSE,sha256=Zb-WJ3pMSCC--ZtZT9v-O61DI3r851K_gGK_-buUtOE,1084
5
+ nextpyper/nextpyper.VERSION,sha256=6d2FB_S_DG9CRY5BrqgzrQvT9hJycjNe7pv01YVB7Wc,6
6
+ nextpyper/config/config.yaml,sha256=b7cDYbjUuZUEdEjI65P80IxgtLRg0T7IBcLCHUQYZ0c,2517
7
+ nextpyper/config/rich_config.yaml,sha256=wjpqo0WmY5GTv99QySdV3ZQP2RFFMSglB0yDDVplxd0,1111
8
+ nextpyper/config/system_config.yaml,sha256=-ApzAXyA6lN-wUOVCjr5SAItUkF4NUMrfoyXxRHrPqI,966
9
+ nextpyper/data/blosum62.csv,sha256=K4dr4L-yfkgnRgSJ0G9VlQP8Due955ec__aT1A4ThUo,2216
10
+ nextpyper/data/cps_seqids.csv,sha256=X7gog13Tuw2lY71XWk3vriDl_xo6uaIquuSfoPoPCpU,23664
11
+ nextpyper/data/mock/mock_args.yaml,sha256=VXGbxQhieI5cSNjGlYZnHdDJkSLnLoYV8-eDV0eI6QE,303
12
+ nextpyper/data/mock/probes.fasta,sha256=p5S4HtP6991Seh7v4GwlLlLmxYea-SmTVs8dsTTj6aw,3221
13
+ nextpyper/data/mock/sample.tsv,sha256=VWt7ne5JGJ-VcACRtgWucy2w7I3KLRz8R-c_-PFMtjk,208
14
+ nextpyper/data/mock/reads/sample1_R1.fastq,sha256=lgZjdHbZ2grC2jz7RJ_fVzOgvchPbjTOqVxi54yDVMc,1710
15
+ nextpyper/data/mock/reads/sample1_R2.fastq,sha256=dSkCFMjPqF8SiE_W8lBwE5TgjGEYjkvDT01ZOowMYxQ,1710
16
+ nextpyper/data/mock/reads/sample2_R1.fastq,sha256=ae8UiwVHyeRPhVQ3KkGRzXI0Twp1n_kl78-7vlf7iSg,1720
17
+ nextpyper/data/mock/reads/sample2_R2.fastq,sha256=uIXhFptuTFRQ30BJBK-LGk3v8fxMnZNxpI24ISxOHuU,1720
18
+ nextpyper/data/mock/reads/sample3_R1.fastq,sha256=FQ9ASpzOuu0-4mTZ-iE0yvBpDtCayFfCNgB0qUDZi6E,1721
19
+ nextpyper/data/mock/reads/sample3_R2.fastq,sha256=gqliBDHmwTbp0wcuucOvc9I-21-xfU7ZjuP6dvNJSM0,1721
20
+ nextpyper/src/divergence_estimation.py,sha256=aBjNEPru0kEEgQgjSeEMxfRY7me1fAWbq_TZU6lt90o,4464
21
+ nextpyper/src/diversity.py,sha256=l6wtq3vwcQHbAFPqiS3p3I3Goh2--uVDDeQmskms0_U,2884
22
+ nextpyper/src/exon_discovery.py,sha256=84ZAPyuJ79KPJb51Do4eIXapAQ4PSgWW0xW6pp41nNw,11064
23
+ nextpyper/src/exon_intron.py,sha256=oDGmqQU1nimp0Vxyvnlj7jg81gHuCJosIljYWqbI_PU,6736
24
+ nextpyper/src/fix_headers.py,sha256=pI8SVesnk5vnck3W3ow2HevUTr0hjHdzWGT3drkEuLo,3262
25
+ nextpyper/src/gfa2fasta.py,sha256=A3XBcd5OnSbNnghAGCzCIndyE6TewCDsviFLhui-YZo,2178
26
+ nextpyper/src/gfa_graph.py,sha256=Ow5kgBCZJu21XY-7dSFZcrwb71GoDZkOPGVN3TmihL0,45865
27
+ nextpyper/src/gff_parser.py,sha256=LT32IY1qgB7Su0wp_9ZHTzy_XeQEou8a2vkyfR_wnNo,12148
28
+ nextpyper/src/graph_utils.py,sha256=LgRTaIyIfuGKMreoNJZx8d40R26mIKFujBfMiZJDBmQ,6284
29
+ nextpyper/src/homolog_filtering.py,sha256=NR4n0aAXId6kCq887Nw9qzr44UUqMSGpQ609Y1QXg-A,14038
30
+ nextpyper/src/miniprot.py,sha256=G6p7vgyPaceohq6jZ-Fs6XoEZGQdZN8qsjkDYivdsyU,40971
31
+ nextpyper/src/multi_seq_probes.py,sha256=i2Y_1PCz4Ph00wC27A-MX2RwFyUxUOpXnKJF6gGTedI,10623
32
+ nextpyper/src/run_orfipy.py,sha256=4XykDuOEJxB0u2TUFpv8Bm9qMfPp1cuYfgm-7bma2yU,18046
33
+ nextpyper/src/sample_table.py,sha256=YhbKNI3fUiVOyZUglnZuK4438I6EgUe7NEZIO1ZRdL0,2215
34
+ nextpyper/src/seeds_collection.py,sha256=tXVRohwQ09yB1ZDxIsdoP5xyVXdJZKdPvdUFICmXkWg,14039
35
+ nextpyper/src/summarize_results.py,sha256=hAkWh8_-zJ6Kor-6g1jX-mZCLXwSKVt4C3ftCOzBKho,17965
36
+ nextpyper/src/union_find.py,sha256=awOxHWSfuN6EmKjg0Tx_kBh22OutPw43WnlQmL22xt4,2141
37
+ nextpyper/src/var_asm_parser.py,sha256=dFJ0qzGZwSIGc9_H1ZOH7mga2RV6dZJ0VXt3x_ioRxE,8216
38
+ nextpyper/test/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ nextpyper/workflow/Snakefile,sha256=OdKv-I3ON1dH73VHkwC8-c8mAvbLDdx6GIJdIOhLeUs,2276
40
+ nextpyper/workflow/envs/alignment.yaml,sha256=UO4gmmg6RYpkPbnUmI2l_fqvMpqH-dEpfOvpsKauQBg,105
41
+ nextpyper/workflow/envs/assembly.yaml,sha256=xgQjY_3ybJ8HRZfLGEPn72Uus-acVIPELsT_BtA59nc,124
42
+ nextpyper/workflow/envs/clustering.yaml,sha256=tOo24TlpZ5aO2g-jalUUnJblx9xwoi7sRKnAgaPgcEo,162
43
+ nextpyper/workflow/envs/matching.yaml,sha256=38RI_rKLKj0Z34Fdx7vNCgEIEiqPJr8VpKdVZnQlgcA,126
44
+ nextpyper/workflow/envs/preprocessing.yaml,sha256=UnqnyfjxQ1aAL0QvzzCxkxCt7NFeBwK6JpDBWzWneS8,199
45
+ nextpyper/workflow/envs/saute.yaml,sha256=ZQWruSUjAoMdLZg6p3tLvCkv1s8JTuhWpAk6kjEy9mc,101
46
+ nextpyper/workflow/envs/translating.yaml,sha256=Y9LsaAur7Rf76CyDIZIhsvE_oMgv1lCo2rOdZkrHhhI,130
47
+ nextpyper/workflow/rules/common.smk,sha256=ujZlVyf0K0DLXdn8BeU70FEzlzV5W0_ZfStv_jeZpwY,5934
48
+ nextpyper/workflow/rules/0_preprocessing/0.1_reads.smk,sha256=hoXBQyR4pckM4xXRb4QHetpyrqguPCxEcBpNQGwuEw8,3240
49
+ nextpyper/workflow/rules/0_preprocessing/0.2_probes.smk,sha256=_m-LqfhwYnCyCzLSQ5KcOttLwjXyf9ukc6dX0gnco3o,552
50
+ nextpyper/workflow/rules/1_seeds_assembly/1.1_assembly_spades.smk,sha256=ftWZq_jJOpA2LYxr2PTy-WFfROTiKepyQEhF2zzA0Jo,1574
51
+ nextpyper/workflow/rules/1_seeds_assembly/1.2_seeds_extension.smk,sha256=4f2KpQkpsiVCPT87v1qPV8Y47IiIEHJidlb8fKYEjj8,3436
52
+ nextpyper/workflow/rules/1_seeds_assembly/1.3_seeds_filtering.smk,sha256=Zdyi3RI08yh0Zn_KCSDA674JoRbURvE74YrdLnDx2GA,2559
53
+ nextpyper/workflow/rules/1_seeds_assembly/1.4_seeds_clustering.smk,sha256=XSukLOavYwF1uhxD08noGCmsjkqq6T-5tbVKvFntcFM,2588
54
+ nextpyper/workflow/rules/2_homologs_assembly/2.1_saute_assembly.smk,sha256=x0X1Fu0pR4OsiNIHgKQ2ChfoiRb9Xj8ZESCj8_u6sno,8648
55
+ nextpyper/workflow/rules/3_homolog_prospection/3.1_allele_collapsing.smk,sha256=gf8QG1eGbTITKI3fp_uznwX-0G2tccOrQDVb7IsUvuE,608
56
+ nextpyper/workflow/rules/3_homolog_prospection/3.2_homologs_filtering.smk,sha256=dVdngWBhzkTN39zDH-l3SeOj7UX-qJJzVwlPNWRYAEU,2772
57
+ nextpyper/workflow/rules/3_homolog_prospection/3.3_region_separation.smk,sha256=uHVvFq5JAQMlApDi5e5RTgTemTO02Dhwau0x1t6Q9no,6636
58
+ nextpyper/workflow/schemas/probes.yaml,sha256=VX0wDfbda4-sE9EKRQa5LfJCg4KSieNhzYwq2VZvJzE,318
59
+ nextpyper/workflow/schemas/sample_table.yaml,sha256=O-OjD7-8Wu7tKkUkN40IKFofAoRemN-xFTSbfRiub4Q,750
60
+ nextpyper/workflow/scripts/bench_busco.py,sha256=ftLgbRQWVo_aaj47CqnnMuc31pPHzxoTf8nm6bDD7Hc,19251
61
+ nextpyper/workflow/scripts/categories_bench.sh,sha256=0fmDkTvQmJ-9MiRUoFjOHPVfThTFch1HctlI3DW7W2I,3131
62
+ nextpyper/workflow/scripts/end_recs_parser.py,sha256=vDSF30trzd7ZSeGVmfP9fA92uQ5u2fH2nj4YkkcmonI,5436
63
+ nextpyper/workflow/scripts/tribble_stats.py,sha256=EACJeEQHaNtlaLG461rxGOt9ZfXysB-BvJwVMC5HNxs,4348
64
+ nextpyper-0.1.0.dist-info/licenses/nextpyper/nextpyper.LICENSE,sha256=Zb-WJ3pMSCC--ZtZT9v-O61DI3r851K_gGK_-buUtOE,1084
65
+ nextpyper-0.1.0.dist-info/METADATA,sha256=lOER-N4owSoIp9ly4mzgkqUki0BJ9ThUJ-useE1yyXQ,9093
66
+ nextpyper-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
67
+ nextpyper-0.1.0.dist-info/entry_points.txt,sha256=JgzW6e83fLWdSKX-xHQhzT6MBANwYX7MW-JLASDE13Q,81
68
+ nextpyper-0.1.0.dist-info/top_level.txt,sha256=HsKGL5xBA9AiuoDMJrtuIHhGw3Hf6TqLTxZHv8FcBWk,10
69
+ nextpyper-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ my-cli = nextpyper.src:cli
3
+ nextpyper = nextpyper.__main__:main
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 Simón Villanueva Corrales, Yann Bertrand
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ nextpyper