GPatch 0.3.4__tar.gz → 0.3.6__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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GPatch
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.
5
5
  Home-page: https://github.com/adadiehl/GPatch
6
6
  Author: Adam Diehl
@@ -40,8 +40,8 @@ Description: # GPatch
40
40
 
41
41
  ## Usage
42
42
  ```
43
- usage: GPatch [-h] -q SAM/BAM -r FASTA [-x BED] [-b FILENAME] [-m N]
44
- [-d N] [-f FLOAT] [-e FLOAT]
43
+ usage: GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N]
44
+ [-w PATH] [-d]
45
45
  ```
46
46
 
47
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.
@@ -59,6 +59,8 @@ Description: # GPatch
59
59
  | __-x STR, --prefix STR__ | Prefix to add to output file names. Default=None |
60
60
  | __-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. |
61
61
  | __-m N, --min_qual_score N__ | Minimum mapping quality score to retain an alignment. Default=30 |
62
+ | __-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
+ | __-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. |
62
64
 
63
65
 
64
66
  ## Output
@@ -32,8 +32,8 @@ Installation from the github repository is not recommended. However, if you must
32
32
 
33
33
  ## Usage
34
34
  ```
35
- usage: GPatch [-h] -q SAM/BAM -r FASTA [-x BED] [-b FILENAME] [-m N]
36
- [-d N] [-f FLOAT] [-e FLOAT]
35
+ usage: GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N]
36
+ [-w PATH] [-d]
37
37
  ```
38
38
 
39
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.
@@ -51,6 +51,8 @@ Starting with alignments of contigs to a reference genome, produce a chromosome-
51
51
  | __-x STR, --prefix STR__ | Prefix to add to output file names. Default=None |
52
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
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. |
54
56
 
55
57
 
56
58
  ## Output
@@ -29,7 +29,7 @@ def main():
29
29
 
30
30
  metadata = dict(
31
31
  name="GPatch",
32
- version="0.3.4",
32
+ version="0.3.6",
33
33
  author="Adam Diehl",
34
34
  author_email="adadiehl@umich.edu",
35
35
  description="Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.",
@@ -7,7 +7,7 @@ from Bio.Seq import Seq
7
7
  import pysam
8
8
  import random
9
9
 
10
- __version__ = "0.3.4"
10
+ __version__ = "0.3.6"
11
11
 
12
12
  """
13
13
  Given a name-sorted BAM file, cluster mapped reads by name and
@@ -45,7 +45,9 @@ def contig_breakpoints_from_cigar(primary_alignments):
45
45
  chrom = contig.reference_name
46
46
  start = contig.reference_start
47
47
  end = contig.reference_end
48
+ #sys.stderr.write("%s\t%s\t%s\n" % (chrom, start, end))
48
49
  # Check for left and right soft-clips
50
+ #sys.stderr.write("%s\n%s\n" % (contig.cigartuples[0], contig.cigartuples[-1]))
49
51
  if contig.cigartuples[0][0] == 4:
50
52
  # left soft-clip
51
53
  start -= contig.cigartuples[0][1]
@@ -53,6 +55,7 @@ def contig_breakpoints_from_cigar(primary_alignments):
53
55
  # right soft-clip
54
56
  end += contig.cigartuples[-1][1]
55
57
  contig_breakpoints[contig.query_name] = [chrom, start, end, contig.query_name]
58
+ #sys.stderr.write("%s\n" % (contig_breakpoints))
56
59
 
57
60
  return contig_breakpoints
58
61
 
@@ -165,8 +168,8 @@ def main():
165
168
  parser.add_argument('-w', '--whitelist', metavar='PATH', type=str,
166
169
  required=False, default=None,
167
170
  help='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')
168
- parser.add_argument('-d', '--drop_missing', type=bool,
169
- required=False, default=False,
171
+ parser.add_argument('-d', '--drop_missing',
172
+ required=False, default=False, action="store_true",
170
173
  help='Omit unpatched reference chromosome records from the output if no contigs map to them. Default: Unpatched chromosomes are printed to output unchanged.')
171
174
 
172
175
  args = parser.parse_args()
@@ -265,11 +268,16 @@ def main():
265
268
  patched_seq = ""
266
269
  for contig in contigs:
267
270
  rstart = contig_breakpoints[contig.query_name][1]
271
+ """
272
+ # This introduced a one-off error! We don't need to do this
273
+ # because all coordinates are already in proper zero-based form.
268
274
  if rstart > 0:
269
275
  rstart -= 1
276
+ """
270
277
 
271
278
  # Check for overlapping/bookended contig mappings.
272
279
  qstart = 0 # Start of contig interval to append
280
+ #sys.stderr.write("%s\t%s\t%s\n" % (rstart, pos, pos-rstart))
273
281
  if rstart > pos:
274
282
  # No overlap. Append the patch, in all lower-case
275
283
  # for easy identification.
@@ -278,7 +286,9 @@ def main():
278
286
  patches_bed.write("%s\t%d\t%d\n" % (ref_seq.id, pos, rstart))
279
287
  else:
280
288
  # Handle overlapping contig ends by trimming the 5' end of
281
- # this contig sequence by the length of the overlap.
289
+ # this contig sequence by the length of the overlap. Note this
290
+ # evaluates to zero if contigs are bookended (i.e., pos and
291
+ # rstart are equal.)
282
292
  qstart = pos - rstart
283
293
 
284
294
  # Append the contig sequence to the patched sequence string
@@ -299,14 +309,17 @@ def main():
299
309
 
300
310
  # Update the current position in the reference sequence if the
301
311
  # end position of the current contig is 3' of the current pos.
312
+ #sys.stderr.write("%s\t%s\t%s\n" % (pos, contig_breakpoints[contig.query_name][2], len(ref_seq.seq)))
302
313
  if contig_breakpoints[contig.query_name][2] > pos:
303
314
  # This should always evaluate true in the absence of nested contigs.
304
315
  pos = contig_breakpoints[contig.query_name][2]
305
-
316
+
306
317
  # Once the above loop finishes, we need to add the terminal segment
307
318
  # from the reference genome.
308
- patched_seq = patched_seq + ref_seq.seq[pos:len(ref_seq.seq)]
309
- patches_bed.write("%s\t%d\t%d\n" % (ref_seq.id, pos, len(ref_seq.seq)))
319
+ if pos < len(ref_seq.seq):
320
+ #sys.stderr.write("%s\n" % (ref_seq.seq[pos:len(ref_seq.seq)]))
321
+ patched_seq = patched_seq + ref_seq.seq[pos:len(ref_seq.seq)]
322
+ patches_bed.write("%s\t%d\t%d\n" % (ref_seq.id, pos, len(ref_seq.seq)))
310
323
 
311
324
  # Swap in the patched sequence for the reference sequence and print the result
312
325
  ref_seq.seq = patched_seq
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GPatch
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Assemble contigs into a chromosome-scalse pseudo-assembly using alignments to a reference sequence.
5
5
  Home-page: https://github.com/adadiehl/GPatch
6
6
  Author: Adam Diehl
@@ -40,8 +40,8 @@ Description: # GPatch
40
40
 
41
41
  ## Usage
42
42
  ```
43
- usage: GPatch [-h] -q SAM/BAM -r FASTA [-x BED] [-b FILENAME] [-m N]
44
- [-d N] [-f FLOAT] [-e FLOAT]
43
+ usage: GPatch.py [-h] -q SAM/BAM -r FASTA [-x STR] [-b FILENAME] [-m N]
44
+ [-w PATH] [-d]
45
45
  ```
46
46
 
47
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.
@@ -59,6 +59,8 @@ Description: # GPatch
59
59
  | __-x STR, --prefix STR__ | Prefix to add to output file names. Default=None |
60
60
  | __-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. |
61
61
  | __-m N, --min_qual_score N__ | Minimum mapping quality score to retain an alignment. Default=30 |
62
+ | __-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
+ | __-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. |
62
64
 
63
65
 
64
66
  ## Output
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes