GPatch 0.3.8__tar.gz → 0.4.0__tar.gz
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.
- {GPatch-0.3.8/src/GPatch.egg-info → gpatch-0.4.0}/PKG-INFO +12 -7
- gpatch-0.4.0/README.md +78 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/setup.py +3 -3
- {GPatch-0.3.8 → gpatch-0.4.0}/src/GPatch/GPatch.py +53 -12
- {GPatch-0.3.8 → gpatch-0.4.0/src/gpatch.egg-info}/PKG-INFO +12 -7
- gpatch-0.4.0/src/gpatch.egg-info/SOURCES.txt +17 -0
- GPatch-0.3.8/README.md +0 -73
- GPatch-0.3.8/src/GPatch.egg-info/SOURCES.txt +0 -17
- {GPatch-0.3.8 → gpatch-0.4.0}/CODE_OF_CONDUCT.md +0 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/LICENSE +0 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/MANIFEST.in +0 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/pyproject.toml +0 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/requirements.txt +0 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/setup.cfg +0 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/src/GPatch/__init__.py +0 -0
- {GPatch-0.3.8 → gpatch-0.4.0}/src/GPatch/__main__.py +0 -0
- {GPatch-0.3.8/src/GPatch.egg-info → gpatch-0.4.0/src/gpatch.egg-info}/dependency_links.txt +0 -0
- {GPatch-0.3.8/src/GPatch.egg-info → gpatch-0.4.0/src/gpatch.egg-info}/entry_points.txt +0 -0
- {GPatch-0.3.8/src/GPatch.egg-info → gpatch-0.4.0/src/gpatch.egg-info}/not-zip-safe +0 -0
- {GPatch-0.3.8/src/GPatch.egg-info → gpatch-0.4.0/src/gpatch.egg-info}/requires.txt +0 -0
- {GPatch-0.3.8/src/GPatch.egg-info → gpatch-0.4.0/src/gpatch.egg-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.
|
|
2
|
+
Name: gpatch
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence. Download the github repository for helper scripts to automate GPatch workflows, identify and correct misjoins in the contig assembly, produce dot-plots of patched pseudoassemblies to a reference assembly, and generate chrom.sizes and liftover chains for patched pseudoassemblies.
|
|
5
5
|
Home-page: https://github.com/adadiehl/GPatch
|
|
6
6
|
Author: Adam Diehl
|
|
7
7
|
Author-email: adadiehl@umich.edu
|
|
@@ -40,11 +40,10 @@ Description: # GPatch
|
|
|
40
40
|
|
|
41
41
|
## Usage
|
|
42
42
|
```
|
|
43
|
-
|
|
44
|
-
[-w PATH] [-d]
|
|
43
|
+
GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N] [-w PATH] [-d] [-s] [-l N] [-e] [-k]
|
|
45
44
|
```
|
|
46
45
|
|
|
47
|
-
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference.
|
|
46
|
+
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference. By default, reference chromosomes with no mapped contigs are printed to output unchanged. Use the --drop_missing option to disable this behavior. By default, patches are applied to the 5' and 3' telomere ends of pseudochromsomes if the first and last contig alignments do not extend to the start/end of the reference chromsome. In some cases, this may cause spurious duplications. Use the --no_extend option if this is a concern. Note that GPatch is designed to be run on single-haplotype or unphased genome assemblies. For phased assemblies, each haplotype should be separated into its own input FASTA file prior to alignment. GPatch can then be run separately on the BAM files for each haplotype to obtain phased pseudoassemblies, otherwise results will be unpredictable and likely incorrect.
|
|
48
47
|
|
|
49
48
|
#### Required Arguments
|
|
50
49
|
| Argument | Description |
|
|
@@ -61,7 +60,10 @@ Description: # GPatch
|
|
|
61
60
|
| __-m N, --min_qual_score N__ | Minimum mapping quality score to retain an alignment. Default=30 |
|
|
62
61
|
| __-w PATH, --whitelist PATH__ | Path to BED file containing whitelist regions: i.e., the inverse of blacklist regions. Supplying this will have the effect of excluding alignments that fall entirely within blacklist regions. Default=None |
|
|
63
62
|
| __-d, --drop_missing__ | Omit unpatched reference chromosome records from the output if no contigs map to them. Default: Unpatched chromosomes are printed to output unchanged. |
|
|
64
|
-
| __-
|
|
63
|
+
| __-s, --scaffold_only__ | Pad gaps between placed contigs with strings of N characters instead of patching with sequence from the reference assembly. Effectively turns GPatch into a reference-guided scaffolding tool. Note that patches.bed will still be generated to document (inverse) mapped contig boundaries in reference frame. |
|
|
64
|
+
| __-l N, --gap_length N__ | Length of "N" gaps separating placed gontigs when using --scaffold_only. Has no effect when in default patching mode. Default=Estimate gap length from alignment. |
|
|
65
|
+
| __-e, --no_extend__ | Do not patch telomere ends of pseudochromosomes with reference sequence upstream of the first mapped contig and downstream of the last mapped contig. Default is to include 5' and 3' patches to extend telomeres to the ends implied by the alignment. |
|
|
66
|
+
| __-k, --keep_nested__ | Do not drop contigs with mapped positions nested entirely inside other mapped contigs. Instead, these will be bookended after the contig in which they are nested. Default is to drop contigs with mapped positions nested entirely within other mapped contigs. This option should be used with caution as these mappings cannot be placed unambigiously relative to other mapped contigs, thus including them is likely to lead to unpredictable and possibly incorrect results. Do not use this unless you are sure you know what you are doing! |
|
|
65
67
|
|
|
66
68
|
## Output
|
|
67
69
|
|
|
@@ -72,6 +74,9 @@ Description: # GPatch
|
|
|
72
74
|
| __contigs.bed__ | Location of contigs in the coordinate frame of the patched genome. |
|
|
73
75
|
| __patches.bed__ | Location of patches in the coordinate frame of the reference genome. |
|
|
74
76
|
|
|
77
|
+
## Helper Scripts
|
|
78
|
+
|
|
79
|
+
The scripts directory contains helper scripts for running GPatch and working with its output, including a shell script to automate a two-stage patching process, including initial alignment and patching steps, misjoin breakpoint prediction and contig-breaking, and subsequent realignment and patching of the split contigs, with dot-plots against the reference assembly created after both patching stages. In addition, scripts are provided to generate a chrom.sizes file for a patched pseudoassembly and a set of liftover chains that can be used to translate features mapped to the unpatched contigs to the patched pseudoassembly. Please see the README.md within the scripts for detailed usage information.
|
|
75
80
|
|
|
76
81
|
## Citing GPatch
|
|
77
82
|
Please use the following citation if you use this software in your work:
|
gpatch-0.4.0/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# GPatch
|
|
2
|
+
## Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.
|
|
3
|
+
|
|
4
|
+
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference.
|
|
5
|
+
|
|
6
|
+
## Dependencies
|
|
7
|
+
* Python >= v3.7
|
|
8
|
+
* samtools (https://github.com/samtools/samtools)
|
|
9
|
+
* biopython (https://biopython.org/)
|
|
10
|
+
* pysam (https://github.com/pysam-developers/pysam)
|
|
11
|
+
* minimap2 (https://github.com/lh3/minimap2)
|
|
12
|
+
|
|
13
|
+
We recommend using minimap2 for alignment, using the -a option to generate SAM output.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
We recommend installing with conda, into a new environment:
|
|
18
|
+
```
|
|
19
|
+
conda create -n GPatch -c conda-forge -c bioconda Bio pysam minimap2 samtools GPatch
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Install with pip:
|
|
23
|
+
```
|
|
24
|
+
pip install GPatch
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Installation from the github repository is not recommended. However, if you must, follow the steps below:
|
|
28
|
+
1) git clone https://github.com/adadiehl/GPatch
|
|
29
|
+
2) cd GPatch/
|
|
30
|
+
3) python3 -m pip install -e .
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
```
|
|
35
|
+
GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N] [-w PATH] [-d] [-s] [-l N] [-e] [-k]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference. By default, reference chromosomes with no mapped contigs are printed to output unchanged. Use the --drop_missing option to disable this behavior. By default, patches are applied to the 5' and 3' telomere ends of pseudochromsomes if the first and last contig alignments do not extend to the start/end of the reference chromsome. In some cases, this may cause spurious duplications. Use the --no_extend option if this is a concern. Note that GPatch is designed to be run on single-haplotype or unphased genome assemblies. For phased assemblies, each haplotype should be separated into its own input FASTA file prior to alignment. GPatch can then be run separately on the BAM files for each haplotype to obtain phased pseudoassemblies, otherwise results will be unpredictable and likely incorrect.
|
|
39
|
+
|
|
40
|
+
#### Required Arguments
|
|
41
|
+
| Argument | Description |
|
|
42
|
+
|---|---|
|
|
43
|
+
| __-q SAM/BAM, --query_bam SAM/BAM__ | Path to SAM/BAM file containing non-overlapping contig mappings to the reference genome. |
|
|
44
|
+
| __-r FASTA, --reference_fasta FASTA__ | Path to reference genome fasta. |
|
|
45
|
+
|
|
46
|
+
#### Optional Arguments:
|
|
47
|
+
| Argument | Description |
|
|
48
|
+
|---|---|
|
|
49
|
+
| __-h, --help__ | Show this help message and exit. |
|
|
50
|
+
| __-x STR, --prefix STR__ | Prefix to add to output file names. Default=None |
|
|
51
|
+
| __-b FILENAME, --store_final_bam FILENAME__ | Store the final set of primary contig alignments to the given file name. Default: Do not store the final BAM. |
|
|
52
|
+
| __-m N, --min_qual_score N__ | Minimum mapping quality score to retain an alignment. Default=30 |
|
|
53
|
+
| __-w PATH, --whitelist PATH__ | Path to BED file containing whitelist regions: i.e., the inverse of blacklist regions. Supplying this will have the effect of excluding alignments that fall entirely within blacklist regions. Default=None |
|
|
54
|
+
| __-d, --drop_missing__ | Omit unpatched reference chromosome records from the output if no contigs map to them. Default: Unpatched chromosomes are printed to output unchanged. |
|
|
55
|
+
| __-s, --scaffold_only__ | Pad gaps between placed contigs with strings of N characters instead of patching with sequence from the reference assembly. Effectively turns GPatch into a reference-guided scaffolding tool. Note that patches.bed will still be generated to document (inverse) mapped contig boundaries in reference frame. |
|
|
56
|
+
| __-l N, --gap_length N__ | Length of "N" gaps separating placed gontigs when using --scaffold_only. Has no effect when in default patching mode. Default=Estimate gap length from alignment. |
|
|
57
|
+
| __-e, --no_extend__ | Do not patch telomere ends of pseudochromosomes with reference sequence upstream of the first mapped contig and downstream of the last mapped contig. Default is to include 5' and 3' patches to extend telomeres to the ends implied by the alignment. |
|
|
58
|
+
| __-k, --keep_nested__ | Do not drop contigs with mapped positions nested entirely inside other mapped contigs. Instead, these will be bookended after the contig in which they are nested. Default is to drop contigs with mapped positions nested entirely within other mapped contigs. This option should be used with caution as these mappings cannot be placed unambigiously relative to other mapped contigs, thus including them is likely to lead to unpredictable and possibly incorrect results. Do not use this unless you are sure you know what you are doing! |
|
|
59
|
+
|
|
60
|
+
## Output
|
|
61
|
+
|
|
62
|
+
GPatch produces three output files:
|
|
63
|
+
| File | Description |
|
|
64
|
+
|---|---|
|
|
65
|
+
| __patched.fasta__ | The final patched genome. |
|
|
66
|
+
| __contigs.bed__ | Location of contigs in the coordinate frame of the patched genome. |
|
|
67
|
+
| __patches.bed__ | Location of patches in the coordinate frame of the reference genome. |
|
|
68
|
+
|
|
69
|
+
## Helper Scripts
|
|
70
|
+
|
|
71
|
+
The scripts directory contains helper scripts for running GPatch and working with its output, including a shell script to automate a two-stage patching process, including initial alignment and patching steps, misjoin breakpoint prediction and contig-breaking, and subsequent realignment and patching of the split contigs, with dot-plots against the reference assembly created after both patching stages. In addition, scripts are provided to generate a chrom.sizes file for a patched pseudoassembly and a set of liftover chains that can be used to translate features mapped to the unpatched contigs to the patched pseudoassembly. Please see the README.md within the scripts for detailed usage information.
|
|
72
|
+
|
|
73
|
+
## Citing GPatch
|
|
74
|
+
Please use the following citation if you use this software in your work:
|
|
75
|
+
|
|
76
|
+
Fast and Accurate Draft Genome Patching with GPatch
|
|
77
|
+
Adam Diehl, Alan Boyle
|
|
78
|
+
bioRxiv 2025.05.22.655567; doi: https://doi.org/10.1101/2025.05.22.655567
|
|
@@ -28,11 +28,11 @@ def readme():
|
|
|
28
28
|
def main():
|
|
29
29
|
|
|
30
30
|
metadata = dict(
|
|
31
|
-
name="
|
|
32
|
-
version="0.
|
|
31
|
+
name="gpatch",
|
|
32
|
+
version="0.4.0",
|
|
33
33
|
author="Adam Diehl",
|
|
34
34
|
author_email="adadiehl@umich.edu",
|
|
35
|
-
description="Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.",
|
|
35
|
+
description="Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence. Download the github repository for helper scripts to automate GPatch workflows, identify and correct misjoins in the contig assembly, produce dot-plots of patched pseudoassemblies to a reference assembly, and generate chrom.sizes and liftover chains for patched pseudoassemblies.",
|
|
36
36
|
long_description=readme(),
|
|
37
37
|
long_description_content_type="text/markdown",
|
|
38
38
|
url="https://github.com/adadiehl/GPatch",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
3
|
import sys, os, re
|
|
4
|
-
from argparse import ArgumentParser
|
|
4
|
+
from argparse import ArgumentParser, SUPPRESS
|
|
5
5
|
from Bio import SeqIO
|
|
6
6
|
from Bio.Seq import Seq
|
|
7
7
|
import pysam
|
|
8
8
|
import random
|
|
9
9
|
|
|
10
|
-
__version__ = "0.
|
|
10
|
+
__version__ = "0.4.0"
|
|
11
11
|
|
|
12
12
|
"""
|
|
13
13
|
Given a name-sorted BAM file, cluster mapped reads by name and
|
|
@@ -148,6 +148,7 @@ def cluster_contig_positions(sorted_contig_intervals, drop_nested=False):
|
|
|
148
148
|
cluster.append(contig)
|
|
149
149
|
else:
|
|
150
150
|
#sys.stderr.write("\tnested\n")
|
|
151
|
+
#sys.stderr.write("\t%s\n\t%s\n" % (cluster[-1], contig))
|
|
151
152
|
pass
|
|
152
153
|
else:
|
|
153
154
|
cluster.append(contig)
|
|
@@ -160,7 +161,7 @@ def cluster_contig_positions(sorted_contig_intervals, drop_nested=False):
|
|
|
160
161
|
|
|
161
162
|
|
|
162
163
|
def main():
|
|
163
|
-
parser = ArgumentParser(description="Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference.")
|
|
164
|
+
parser = ArgumentParser(description="Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference. By default, reference chromosomes with no mapped contigs are printed to output unchanged. Use the --drop_missing option to disable this behavior. By default, patches are applied to the 5' and 3' telomere ends of pseudochromsomes if the first and last contig alignments do not extend to the start/end of the reference chromsome. In some cases, this may cause spurious duplications. Use the --no_extend option if this is a concern. Note that GPatch is designed to be run on single-haplotype or unphased genome assemblies. For phased assemblies, each haplotype should be separated into its own input FASTA file prior to alignment. GPatch can then be run separately on the BAM files for each haplotype to obtain phased pseudoassemblies, otherwise results will be unpredictable and likely incorrect.")
|
|
164
165
|
parser.add_argument('-q', '--query_bam', metavar='SAM/BAM', type=str,
|
|
165
166
|
required=True, help='Path to SAM/BAM file containing non-overlapping contig mappings to the reference genome.')
|
|
166
167
|
parser.add_argument('-r', '--reference_fasta', metavar='FASTA', type=str,
|
|
@@ -180,9 +181,25 @@ def main():
|
|
|
180
181
|
parser.add_argument('-d', '--drop_missing',
|
|
181
182
|
required=False, default=False, action="store_true",
|
|
182
183
|
help='Omit unpatched reference chromosome records from the output if no contigs map to them. Default: Unpatched chromosomes are printed to output unchanged.')
|
|
184
|
+
# Note the --no_trim option is deprecated in versions 0.4.0. Trimming
|
|
185
|
+
# is disabled as it had universally negative effects in our testing
|
|
186
|
+
# and should not be used.
|
|
183
187
|
parser.add_argument('-t', '--no_trim',
|
|
188
|
+
required=False, default=True, action="store_true",
|
|
189
|
+
#help='Do not trim the 5-prime end of contigs whose mappings overlap the previously-placed contig. Default: Overlapping contig sequence will be trimmed at the previous 3-prime contig breakpoint.')
|
|
190
|
+
help=SUPPRESS)
|
|
191
|
+
parser.add_argument('-s', '--scaffold_only',
|
|
184
192
|
required=False, default=False, action="store_true",
|
|
185
|
-
help='
|
|
193
|
+
help='Pad gaps between placed contigs with strings of N characters instead of patching with sequence from the reference assembly. Effectively turns GPatch into a reference-guided scaffolding tool. Note that patches.bed will still be generated to document (inverse) mapped contig boundaries in reference frame.')
|
|
194
|
+
parser.add_argument('-l', '--gap_length', metavar='N', type=int,
|
|
195
|
+
required=False, default=-1,
|
|
196
|
+
help='Length of "N" gaps separating placed gontigs when using --scaffold_only. Has no effect when in default patching mode. Default=Estimate gap length from alignment.')
|
|
197
|
+
parser.add_argument('-e', '--no_extend',
|
|
198
|
+
required=False, default=False, action="store_true",
|
|
199
|
+
help='Do not patch telomere ends of pseudochromosomes with reference sequence upstream of the first mapped contig and downstream of the last mapped contig. Default is to include 5\' and 3\' patches to extend telomeres to the ends implied by the alignment.')
|
|
200
|
+
parser.add_argument('-k', '--keep_nested',
|
|
201
|
+
required=False, default=False, action="store_true",
|
|
202
|
+
help='Do not drop contigs with mapped positions nested entirely inside other mapped contigs. Instead, these will be bookended after the contig in which they are nested. Default is to drop contigs with mapped positions nested entirely within other mapped contigs. This option should be used with caution as these mappings cannot be placed unambigiously relative to other mapped contigs, thus including them is likely to lead to unpredictable and possibly incorrect results. Do not use this unless you are sure you know what you are doing!')
|
|
186
203
|
|
|
187
204
|
args = parser.parse_args()
|
|
188
205
|
|
|
@@ -213,7 +230,8 @@ def main():
|
|
|
213
230
|
os.rename(filtered_bam + '.bai', sorted_primary_alignments_bam + ".bai")
|
|
214
231
|
|
|
215
232
|
# Check for nested/overlapping alignment spaces among the remaining contigs.
|
|
216
|
-
|
|
233
|
+
if not args.keep_nested:
|
|
234
|
+
sys.stderr.write("Checking for nested contigs...\n")
|
|
217
235
|
sorted_primary_alignments = pysam.AlignmentFile(sorted_primary_alignments_bam, "rb")
|
|
218
236
|
final_alignments = []
|
|
219
237
|
for ref_seq in SeqIO.parse(args.reference_fasta, "fasta"):
|
|
@@ -226,7 +244,10 @@ def main():
|
|
|
226
244
|
sorted_contig_intervals = contigs_to_sorted_interval_list(contigs, contig_breakpoints)
|
|
227
245
|
|
|
228
246
|
# Cluster the linear intervals on overlap, leaving out nested contigs
|
|
229
|
-
|
|
247
|
+
drop_nested = True
|
|
248
|
+
if args.keep_nested:
|
|
249
|
+
drop_nested = False
|
|
250
|
+
clusters = cluster_contig_positions(sorted_contig_intervals, drop_nested=drop_nested)
|
|
230
251
|
|
|
231
252
|
# Next thing to do is to push all retained contigs across clusters into
|
|
232
253
|
# a final list of useful contigs. Since pysam.fetch does not allow
|
|
@@ -242,9 +263,13 @@ def main():
|
|
|
242
263
|
final_alignments.append(contig)
|
|
243
264
|
|
|
244
265
|
sorted_primary_alignments.close()
|
|
245
|
-
|
|
266
|
+
|
|
267
|
+
# Clean up the initial sorted BAM and index files.
|
|
268
|
+
os.remove(sorted_primary_alignments_bam)
|
|
269
|
+
os.remove(sorted_primary_alignments_bam + '.bai')
|
|
270
|
+
|
|
246
271
|
# Write the final set of alignments to a sorted BAM file
|
|
247
|
-
sorted_primary_alignments_bam = sorted_bam_from_aln_list(final_alignments, query_bam.header, sorted_bam_name=args.store_final_bam)
|
|
272
|
+
sorted_primary_alignments_bam = sorted_bam_from_aln_list(final_alignments, query_bam.header, sorted_bam_name=args.store_final_bam)
|
|
248
273
|
pysam.index(sorted_primary_alignments_bam)
|
|
249
274
|
|
|
250
275
|
# Set up output streams for fasta, patches.bed, and contigs.bed
|
|
@@ -294,14 +319,30 @@ def main():
|
|
|
294
319
|
if rstart > pos:
|
|
295
320
|
# No overlap. Append the patch, in all lower-case
|
|
296
321
|
# for easy identification.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
322
|
+
patch = ""
|
|
323
|
+
if args.scaffold_only:
|
|
324
|
+
# Use a string of N characters the length of the patch instead
|
|
325
|
+
# of an actual patch.
|
|
326
|
+
if args.gap_length >= 0:
|
|
327
|
+
patch = "n" * args.gap_length
|
|
328
|
+
else:
|
|
329
|
+
patch = "n" * (rstart-pos)
|
|
330
|
+
else:
|
|
331
|
+
patch = ref_seq.seq[pos:rstart].lower()
|
|
332
|
+
if pos == 0 and args.no_extend:
|
|
333
|
+
pass
|
|
334
|
+
else:
|
|
335
|
+
patched_seq = patched_seq + patch
|
|
336
|
+
# Write patch coordinates in reference frame to patches_bed
|
|
337
|
+
patches_bed.write("%s\t%d\t%d\n" % (ref_seq.id, pos, rstart))
|
|
300
338
|
else:
|
|
301
339
|
# Handle overlapping contig ends by trimming the 5' end of
|
|
302
340
|
# this contig sequence by the length of the overlap. Note this
|
|
303
341
|
# evaluates to zero if contigs are bookended (i.e., pos and
|
|
304
342
|
# rstart are equal.)
|
|
343
|
+
#
|
|
344
|
+
# NOTE THAT THIS BEHAVIOR IS DEPRECATED AND THE OPTION TO TRIM
|
|
345
|
+
# IS DISABLED IN VERSIONS 0.4.0 AND GREATER.
|
|
305
346
|
if not args.no_trim:
|
|
306
347
|
qstart = pos - rstart
|
|
307
348
|
if qstart > len(Seq(contig.query_sequence)):
|
|
@@ -337,7 +378,7 @@ def main():
|
|
|
337
378
|
|
|
338
379
|
# Once the above loop finishes, we need to add the terminal segment
|
|
339
380
|
# from the reference genome.
|
|
340
|
-
if pos < len(ref_seq.seq):
|
|
381
|
+
if pos < len(ref_seq.seq) and not args.no_extend:
|
|
341
382
|
#sys.stderr.write("%s\n" % (ref_seq.seq[pos:len(ref_seq.seq)]))
|
|
342
383
|
patched_seq = patched_seq + ref_seq.seq[pos:len(ref_seq.seq)]
|
|
343
384
|
patches_bed.write("%s\t%d\t%d\n" % (ref_seq.id, pos, len(ref_seq.seq)))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.
|
|
2
|
+
Name: gpatch
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence. Download the github repository for helper scripts to automate GPatch workflows, identify and correct misjoins in the contig assembly, produce dot-plots of patched pseudoassemblies to a reference assembly, and generate chrom.sizes and liftover chains for patched pseudoassemblies.
|
|
5
5
|
Home-page: https://github.com/adadiehl/GPatch
|
|
6
6
|
Author: Adam Diehl
|
|
7
7
|
Author-email: adadiehl@umich.edu
|
|
@@ -40,11 +40,10 @@ Description: # GPatch
|
|
|
40
40
|
|
|
41
41
|
## Usage
|
|
42
42
|
```
|
|
43
|
-
|
|
44
|
-
[-w PATH] [-d]
|
|
43
|
+
GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N] [-w PATH] [-d] [-s] [-l N] [-e] [-k]
|
|
45
44
|
```
|
|
46
45
|
|
|
47
|
-
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference.
|
|
46
|
+
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference. By default, reference chromosomes with no mapped contigs are printed to output unchanged. Use the --drop_missing option to disable this behavior. By default, patches are applied to the 5' and 3' telomere ends of pseudochromsomes if the first and last contig alignments do not extend to the start/end of the reference chromsome. In some cases, this may cause spurious duplications. Use the --no_extend option if this is a concern. Note that GPatch is designed to be run on single-haplotype or unphased genome assemblies. For phased assemblies, each haplotype should be separated into its own input FASTA file prior to alignment. GPatch can then be run separately on the BAM files for each haplotype to obtain phased pseudoassemblies, otherwise results will be unpredictable and likely incorrect.
|
|
48
47
|
|
|
49
48
|
#### Required Arguments
|
|
50
49
|
| Argument | Description |
|
|
@@ -61,7 +60,10 @@ Description: # GPatch
|
|
|
61
60
|
| __-m N, --min_qual_score N__ | Minimum mapping quality score to retain an alignment. Default=30 |
|
|
62
61
|
| __-w PATH, --whitelist PATH__ | Path to BED file containing whitelist regions: i.e., the inverse of blacklist regions. Supplying this will have the effect of excluding alignments that fall entirely within blacklist regions. Default=None |
|
|
63
62
|
| __-d, --drop_missing__ | Omit unpatched reference chromosome records from the output if no contigs map to them. Default: Unpatched chromosomes are printed to output unchanged. |
|
|
64
|
-
| __-
|
|
63
|
+
| __-s, --scaffold_only__ | Pad gaps between placed contigs with strings of N characters instead of patching with sequence from the reference assembly. Effectively turns GPatch into a reference-guided scaffolding tool. Note that patches.bed will still be generated to document (inverse) mapped contig boundaries in reference frame. |
|
|
64
|
+
| __-l N, --gap_length N__ | Length of "N" gaps separating placed gontigs when using --scaffold_only. Has no effect when in default patching mode. Default=Estimate gap length from alignment. |
|
|
65
|
+
| __-e, --no_extend__ | Do not patch telomere ends of pseudochromosomes with reference sequence upstream of the first mapped contig and downstream of the last mapped contig. Default is to include 5' and 3' patches to extend telomeres to the ends implied by the alignment. |
|
|
66
|
+
| __-k, --keep_nested__ | Do not drop contigs with mapped positions nested entirely inside other mapped contigs. Instead, these will be bookended after the contig in which they are nested. Default is to drop contigs with mapped positions nested entirely within other mapped contigs. This option should be used with caution as these mappings cannot be placed unambigiously relative to other mapped contigs, thus including them is likely to lead to unpredictable and possibly incorrect results. Do not use this unless you are sure you know what you are doing! |
|
|
65
67
|
|
|
66
68
|
## Output
|
|
67
69
|
|
|
@@ -72,6 +74,9 @@ Description: # GPatch
|
|
|
72
74
|
| __contigs.bed__ | Location of contigs in the coordinate frame of the patched genome. |
|
|
73
75
|
| __patches.bed__ | Location of patches in the coordinate frame of the reference genome. |
|
|
74
76
|
|
|
77
|
+
## Helper Scripts
|
|
78
|
+
|
|
79
|
+
The scripts directory contains helper scripts for running GPatch and working with its output, including a shell script to automate a two-stage patching process, including initial alignment and patching steps, misjoin breakpoint prediction and contig-breaking, and subsequent realignment and patching of the split contigs, with dot-plots against the reference assembly created after both patching stages. In addition, scripts are provided to generate a chrom.sizes file for a patched pseudoassembly and a set of liftover chains that can be used to translate features mapped to the unpatched contigs to the patched pseudoassembly. Please see the README.md within the scripts for detailed usage information.
|
|
75
80
|
|
|
76
81
|
## Citing GPatch
|
|
77
82
|
Please use the following citation if you use this software in your work:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
./CODE_OF_CONDUCT.md
|
|
6
|
+
./LICENSE
|
|
7
|
+
./requirements.txt
|
|
8
|
+
src/GPatch/GPatch.py
|
|
9
|
+
src/GPatch/__init__.py
|
|
10
|
+
src/GPatch/__main__.py
|
|
11
|
+
src/gpatch.egg-info/PKG-INFO
|
|
12
|
+
src/gpatch.egg-info/SOURCES.txt
|
|
13
|
+
src/gpatch.egg-info/dependency_links.txt
|
|
14
|
+
src/gpatch.egg-info/entry_points.txt
|
|
15
|
+
src/gpatch.egg-info/not-zip-safe
|
|
16
|
+
src/gpatch.egg-info/requires.txt
|
|
17
|
+
src/gpatch.egg-info/top_level.txt
|
GPatch-0.3.8/README.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# GPatch
|
|
2
|
-
## Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.
|
|
3
|
-
|
|
4
|
-
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference.
|
|
5
|
-
|
|
6
|
-
## Dependencies
|
|
7
|
-
* Python >= v3.7
|
|
8
|
-
* samtools (https://github.com/samtools/samtools)
|
|
9
|
-
* biopython (https://biopython.org/)
|
|
10
|
-
* pysam (https://github.com/pysam-developers/pysam)
|
|
11
|
-
* minimap2 (https://github.com/lh3/minimap2)
|
|
12
|
-
|
|
13
|
-
We recommend using minimap2 for alignment, using the -a option to generate SAM output.
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
We recommend installing with conda, into a new environment:
|
|
18
|
-
```
|
|
19
|
-
conda create -n GPatch -c conda-forge -c bioconda Bio pysam minimap2 samtools GPatch
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Install with pip:
|
|
23
|
-
```
|
|
24
|
-
pip install GPatch
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Installation from the github repository is not recommended. However, if you must, follow the steps below:
|
|
28
|
-
1) git clone https://github.com/adadiehl/GPatch
|
|
29
|
-
2) cd GPatch/
|
|
30
|
-
3) python3 -m pip install -e .
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Usage
|
|
34
|
-
```
|
|
35
|
-
usage: GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N]
|
|
36
|
-
[-w PATH] [-d]
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Starting with alignments of contigs to a reference genome, produce a chromosome-scale pseudoassembly by patching gaps between mapped contigs with sequences from the reference. Reference chromosomes with no mapped contigs are printed to output unchanged.
|
|
40
|
-
|
|
41
|
-
#### Required Arguments
|
|
42
|
-
| Argument | Description |
|
|
43
|
-
|---|---|
|
|
44
|
-
| __-q SAM/BAM, --query_bam SAM/BAM__ | Path to SAM/BAM file containing non-overlapping contig mappings to the reference genome. |
|
|
45
|
-
| __-r FASTA, --reference_fasta FASTA__ | Path to reference genome fasta. |
|
|
46
|
-
|
|
47
|
-
#### Optional Arguments:
|
|
48
|
-
| Argument | Description |
|
|
49
|
-
|---|---|
|
|
50
|
-
| __-h, --help__ | Show this help message and exit. |
|
|
51
|
-
| __-x STR, --prefix STR__ | Prefix to add to output file names. Default=None |
|
|
52
|
-
| __-b FILENAME, --store_final_bam FILENAME__ | Store the final set of primary contig alignments to the given file name. Default: Do not store the final BAM. |
|
|
53
|
-
| __-m N, --min_qual_score N__ | Minimum mapping quality score to retain an alignment. Default=30 |
|
|
54
|
-
| __-w PATH, --whitelist PATH__ | Path to BED file containing whitelist regions: i.e., the inverse of blacklist regions. Supplying this will have the effect of excluding alignments that fall entirely within blacklist regions. Default=None |
|
|
55
|
-
| __-d, --drop_missing__ | Omit unpatched reference chromosome records from the output if no contigs map to them. Default: Unpatched chromosomes are printed to output unchanged. |
|
|
56
|
-
| __-t, --no_trim__ | Do not trim the 5-prime end of contigs whose mappings overlap the previously-placed contig. Default: Overlapping contig sequence will be trimmed at the previous 3-prime contig breakpoint. |
|
|
57
|
-
|
|
58
|
-
## Output
|
|
59
|
-
|
|
60
|
-
GPatch produces three output files:
|
|
61
|
-
| File | Description |
|
|
62
|
-
|---|---|
|
|
63
|
-
| __patched.fasta__ | The final patched genome. |
|
|
64
|
-
| __contigs.bed__ | Location of contigs in the coordinate frame of the patched genome. |
|
|
65
|
-
| __patches.bed__ | Location of patches in the coordinate frame of the reference genome. |
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
## Citing GPatch
|
|
69
|
-
Please use the following citation if you use this software in your work:
|
|
70
|
-
|
|
71
|
-
Fast and Accurate Draft Genome Patching with GPatch
|
|
72
|
-
Adam Diehl, Alan Boyle
|
|
73
|
-
bioRxiv 2025.05.22.655567; doi: https://doi.org/10.1101/2025.05.22.655567
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
MANIFEST.in
|
|
2
|
-
README.md
|
|
3
|
-
pyproject.toml
|
|
4
|
-
setup.py
|
|
5
|
-
./CODE_OF_CONDUCT.md
|
|
6
|
-
./LICENSE
|
|
7
|
-
./requirements.txt
|
|
8
|
-
src/GPatch/GPatch.py
|
|
9
|
-
src/GPatch/__init__.py
|
|
10
|
-
src/GPatch/__main__.py
|
|
11
|
-
src/GPatch.egg-info/PKG-INFO
|
|
12
|
-
src/GPatch.egg-info/SOURCES.txt
|
|
13
|
-
src/GPatch.egg-info/dependency_links.txt
|
|
14
|
-
src/GPatch.egg-info/entry_points.txt
|
|
15
|
-
src/GPatch.egg-info/not-zip-safe
|
|
16
|
-
src/GPatch.egg-info/requires.txt
|
|
17
|
-
src/GPatch.egg-info/top_level.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|