GPatch 0.3.6__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
- Name: GPatch
3
- Version: 0.3.6
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
- usage: GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N]
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. Reference chromosomes with no mapped contigs are printed to output unchanged.
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,11 +74,17 @@ 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:
78
83
 
79
- CITATION_HERE
84
+ Fast and Accurate Draft Genome Patching with GPatch
85
+ Adam Diehl, Alan Boyle
86
+ bioRxiv 2025.05.22.655567; doi: https://doi.org/10.1101/2025.05.22.655567
87
+
80
88
  Keywords: genomics,genome assembly
81
89
  Platform: UNKNOWN
82
90
  Classifier: Development Status :: 4 - Beta
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="GPatch",
32
- version="0.3.6",
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.3.6"
10
+ __version__ = "0.4.0"
11
11
 
12
12
  """
13
13
  Given a name-sorted BAM file, cluster mapped reads by name and
@@ -21,16 +21,25 @@ def create_primary_alignments_list(query_bam, min_qual_score):
21
21
  Extract all primary alignments from the BAM file and return
22
22
  as a list.
23
23
  """
24
+ #i = 0
25
+ #j = 0
26
+ #k = 0
27
+ #l = 0
24
28
  ret = []
25
29
  for aln in query_bam:
30
+ #i += 1
26
31
  if aln.is_unmapped:
27
32
  # Skip unmapped contigs
33
+ #j += 1
28
34
  continue
29
35
  if aln.mapping_quality < min_qual_score:
30
36
  # Skip low-quality mappings
37
+ #k += 1
31
38
  continue
32
39
  if not (aln.is_supplementary or aln.is_secondary):
40
+ #l += 1
33
41
  ret.append(aln)
42
+ #sys.stderr.write("%d\t%d\t%d\t%d\t%d\n" % (i, j, k, l, len(ret)))
34
43
  return ret
35
44
 
36
45
 
@@ -139,6 +148,7 @@ def cluster_contig_positions(sorted_contig_intervals, drop_nested=False):
139
148
  cluster.append(contig)
140
149
  else:
141
150
  #sys.stderr.write("\tnested\n")
151
+ #sys.stderr.write("\t%s\n\t%s\n" % (cluster[-1], contig))
142
152
  pass
143
153
  else:
144
154
  cluster.append(contig)
@@ -151,7 +161,7 @@ def cluster_contig_positions(sorted_contig_intervals, drop_nested=False):
151
161
 
152
162
 
153
163
  def main():
154
- 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.")
155
165
  parser.add_argument('-q', '--query_bam', metavar='SAM/BAM', type=str,
156
166
  required=True, help='Path to SAM/BAM file containing non-overlapping contig mappings to the reference genome.')
157
167
  parser.add_argument('-r', '--reference_fasta', metavar='FASTA', type=str,
@@ -171,6 +181,25 @@ def main():
171
181
  parser.add_argument('-d', '--drop_missing',
172
182
  required=False, default=False, action="store_true",
173
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.
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',
192
+ required=False, default=False, action="store_true",
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!')
174
203
 
175
204
  args = parser.parse_args()
176
205
 
@@ -201,19 +230,24 @@ def main():
201
230
  os.rename(filtered_bam + '.bai', sorted_primary_alignments_bam + ".bai")
202
231
 
203
232
  # Check for nested/overlapping alignment spaces among the remaining contigs.
204
- sys.stderr.write("Checking for nested or overlapping contigs...\n")
233
+ if not args.keep_nested:
234
+ sys.stderr.write("Checking for nested contigs...\n")
205
235
  sorted_primary_alignments = pysam.AlignmentFile(sorted_primary_alignments_bam, "rb")
206
236
  final_alignments = []
207
237
  for ref_seq in SeqIO.parse(args.reference_fasta, "fasta"):
208
238
  # Select all contigs mapped to this sequence.
209
239
  contigs = list(sorted_primary_alignments.fetch(ref_seq.id))
240
+ #sys.stderr.write("%s\t%s\n" % (ref_seq.id, contigs))
210
241
 
211
242
  # Convert the list of contigs into a list of tuples: (start, end, name),
212
243
  # representing the inferred contig breakpoints, sorted by start, then end position.
213
244
  sorted_contig_intervals = contigs_to_sorted_interval_list(contigs, contig_breakpoints)
214
245
 
215
246
  # Cluster the linear intervals on overlap, leaving out nested contigs
216
- clusters = cluster_contig_positions(sorted_contig_intervals, drop_nested=True)
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)
217
251
 
218
252
  # Next thing to do is to push all retained contigs across clusters into
219
253
  # a final list of useful contigs. Since pysam.fetch does not allow
@@ -229,9 +263,13 @@ def main():
229
263
  final_alignments.append(contig)
230
264
 
231
265
  sorted_primary_alignments.close()
232
-
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
+
233
271
  # Write the final set of alignments to a sorted BAM file
234
- 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)
235
273
  pysam.index(sorted_primary_alignments_bam)
236
274
 
237
275
  # Set up output streams for fasta, patches.bed, and contigs.bed
@@ -281,15 +319,39 @@ def main():
281
319
  if rstart > pos:
282
320
  # No overlap. Append the patch, in all lower-case
283
321
  # for easy identification.
284
- patched_seq = patched_seq + ref_seq.seq[pos:rstart].lower()
285
- # Write patch coordinates in reference frame to patches_bed
286
- patches_bed.write("%s\t%d\t%d\n" % (ref_seq.id, pos, rstart))
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))
287
338
  else:
288
339
  # Handle overlapping contig ends by trimming the 5' end of
289
340
  # this contig sequence by the length of the overlap. Note this
290
341
  # evaluates to zero if contigs are bookended (i.e., pos and
291
342
  # rstart are equal.)
292
- qstart = pos - rstart
343
+ #
344
+ # NOTE THAT THIS BEHAVIOR IS DEPRECATED AND THE OPTION TO TRIM
345
+ # IS DISABLED IN VERSIONS 0.4.0 AND GREATER.
346
+ if not args.no_trim:
347
+ qstart = pos - rstart
348
+ if qstart > len(Seq(contig.query_sequence)):
349
+ # This should not happen, as it is indicative of a nested
350
+ # mapping, which should be filtered out prior to sequence-
351
+ # building. However, I have seen instances of nested mappings
352
+ # that somehow slip through the cracks. This is a hack to fix
353
+ # those instances until I can figure out why it happens.
354
+ continue
293
355
 
294
356
  # Append the contig sequence to the patched sequence string
295
357
  contig_start = len(patched_seq)
@@ -316,7 +378,7 @@ def main():
316
378
 
317
379
  # Once the above loop finishes, we need to add the terminal segment
318
380
  # from the reference genome.
319
- if pos < len(ref_seq.seq):
381
+ if pos < len(ref_seq.seq) and not args.no_extend:
320
382
  #sys.stderr.write("%s\n" % (ref_seq.seq[pos:len(ref_seq.seq)]))
321
383
  patched_seq = patched_seq + ref_seq.seq[pos:len(ref_seq.seq)]
322
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: GPatch
3
- Version: 0.3.6
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
- usage: GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N]
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. Reference chromosomes with no mapped contigs are printed to output unchanged.
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,11 +74,17 @@ 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:
78
83
 
79
- CITATION_HERE
84
+ Fast and Accurate Draft Genome Patching with GPatch
85
+ Adam Diehl, Alan Boyle
86
+ bioRxiv 2025.05.22.655567; doi: https://doi.org/10.1101/2025.05.22.655567
87
+
80
88
  Keywords: genomics,genome assembly
81
89
  Platform: UNKNOWN
82
90
  Classifier: Development Status :: 4 - Beta
@@ -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.6/README.md DELETED
@@ -1,71 +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
-
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
- CITATION_HERE
@@ -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