Skip to content

Commit

Permalink
Added --extend-by function
Browse files Browse the repository at this point in the history
  • Loading branch information
Acribbs committed Aug 23, 2024
1 parent 05b8beb commit 395d05d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cgat/tools/bed2fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main(argv=None):
"sequences, one in each direction, for each bed "
"interval. 'segments' can be used to output "
"sequence from bed12 files so that sequence only covers "
"the segements ")
"the segments ")

parser.add_argument("--min-sequence-length", dest="min_length", type=int,
help="require a minimum sequence length ")
Expand Down Expand Up @@ -130,6 +130,13 @@ def main(argv=None):
else:
strand = bed.strand

# Apply the --extend-by logic
if args.extend_by:
if args.extend_at in ("both", "3", "3only"):
bed.end = min(bed.end + args.extend_by, lcontig)
if args.extend_at in ("both", "5", "5only"):
bed.start = max(0, bed.start - args.extend_by)

if args.output_mode == "segments" and bed.columns == 12:
ids.append("%s %s:%i..%i (%s) %s %s" %
(bed.name, bed.contig, bed.start, bed.end, strand,
Expand Down Expand Up @@ -175,3 +182,4 @@ def main(argv=None):

if __name__ == "__main__":
sys.exit(main(sys.argv))

0 comments on commit 395d05d

Please sign in to comment.