Skip to content

Commit d28a154

Browse files
committed
all option to allow N bases in contigs
1 parent 5b3ede6 commit d28a154

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

bin/addsv.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,21 @@ def makemut(args, bedline, alignopts):
431431

432432
trn_maxcontig = sorted(trn_contigs)[-1]
433433

434-
# be strict about contig quality
435434
if re.search('N', maxcontig.seq):
436-
sys.stderr.write("WARN\t" + now() + "\t" + mutid + "\tcontig dropped due to ambiguous base (N), aborting mutation.\n")
437-
return None, None
435+
if args.allowN:
436+
sys.stderr.write("WARN\t" + now() + "\t" + mutid + "\tcontig has ambiguous base (N), replaced with 'A'\n")
437+
maxcontig.seq = re.sub('N', 'A', maxcontig.seq)
438+
else:
439+
sys.stderr.write("WARN\t" + now() + "\t" + mutid + "\tcontig dropped due to ambiguous base (N), aborting mutation.\n")
440+
return None, None
438441

439442
if is_transloc and re.search('N', trn_maxcontig.seq):
440-
sys.stderr.write("WARN\t" + now() + "\t" + mutid + "\tcontig dropped due to ambiguous base (N), aborting mutation.\n")
441-
return None, None
443+
if args.allowN:
444+
sys.stderr.write("WARN\t" + now() + "\t" + mutid + "\tcontig has ambiguous base (N), replaced with 'A'\n")
445+
trn_maxcontig.seq = re.sub('N', 'A', trn_maxcontig.seq)
446+
else:
447+
sys.stderr.write("WARN\t" + now() + "\t" + mutid + "\tcontig dropped due to ambiguous base (N), aborting mutation.\n")
448+
return None, None
442449

443450
if maxcontig is None:
444451
sys.stderr.write("WARN\t" + now() + "\t" + mutid + "\tmaxcontig has length 0, aborting mutation!\n")
@@ -839,6 +846,8 @@ def main(args):
839846
help='temporary directory (default=addsv.tmp)')
840847
parser.add_argument('--seed', default=None,
841848
help='seed random number generation')
849+
parser.add_argument('--allowN', action='store_true', default=False,
850+
help='allow N in contigs, replace with A and warn user (default: drop mutation)')
842851
args = parser.parse_args()
843852
main(args)
844853

0 commit comments

Comments
 (0)