Skip to content

Commit 4f2b299

Browse files
committed
work on examples
1 parent cd67ace commit 4f2b299

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ struct Args {
6464
default_value = "1"
6565
)]
6666
a_requirements: OverlapAmount,
67+
68+
#[arg(
69+
help = "b-requirements for overlap. A float value < 1 or a number ending with % will be the fraction (or %) of the interval. An integer will be the number of bases.",
70+
short = 'R',
71+
long = "b-requirements",
72+
default_value = "1"
73+
)]
74+
b_requirements: OverlapAmount,
6775
}
6876

6977
#[global_allocator]
@@ -137,6 +145,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
137145
.a_part(args.a_part)
138146
.b_part(args.b_part)
139147
.a_requirements(args.a_requirements)
148+
.b_requirements(args.b_requirements)
140149
.build(),
141150
);
142151
log::info!("report_options: {:?}", report_options);

src/writer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ impl Writer {
133133
Some(f) => f,
134134
None => unimplemented!("format must be specified"),
135135
};
136+
let path = if path == "-" { "/dev/stdout" } else { path };
136137

137138
// Use default compression if not specified
138139
let compression = compression.unwrap_or(Compression::None);

tests/examples/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Here we show examples of how `bedder` can perform intersections. All examples uses these files:
2+
3+
#### aa.bed
4+
5+
```
6+
chr1 2 23
7+
```
8+
9+
#### bb.bed
10+
11+
```
12+
chr1 8 12
13+
chr1 14 15
14+
chr1 20 30
15+
```
16+
17+
# Reporting Part
18+
19+
For, now, we focus on which part of each interval that is reported. The options for this are:
20+
21+
```
22+
-p, --a-part <A_PART>
23+
a-part [default: whole] [possible values: none, part, whole, inverse]
24+
--b-part <B_PART>
25+
b-part [default: whole] [possible values: none, part, whole, inverse]
26+
```
27+
28+
Let's start with reporting the *whole* `a` interval if it overlaps and *none* of the `b` interval:
29+
30+
```
31+
$ bedder -a tests/examples/aa.bed -b tests/examples/bb.bed -g tests/examples/fake.fai --a-part whole --b-part none
32+
chr1 2 23
33+
```
34+
35+
Now, we report the *part*s of the `a` interval along with the *whole* `b` interval that it overlapped:
36+
37+
```
38+
$ bedder -a tests/examples/aa.bed -b tests/examples/bb.bed -g tests/examples/fake.fai --a-part part --b-part whole
39+
chr1 8 12 chr1 8 12
40+
chr1 14 15 chr1 14 15
41+
chr1 20 23 chr1 20 30
42+
```
43+
44+
And now the *part* of `a` and the `part` of `b`:
45+
46+
```
47+
$ bedder -a tests/examples/aa.bed -b tests/examples/bb.bed -g tests/examples/fake.fai --a-part part --b-part part
48+
chr1 8 12 chr1 8 12
49+
chr1 14 15 chr1 14 15
50+
chr1 20 23 chr1 20 23
51+
```
52+
53+
We can also report the `inverse` that is, parts of `a` that do not overlap `b`:
54+
55+
```
56+
$ bedder -a tests/examples/aa.bed -b tests/examples/bb.bed -g tests/examples/fake.fai --a-part inverse --b-part none
57+
chr1 2 8
58+
chr1 12 14
59+
chr1 15 20
60+
```
61+
62+
There are other combinations of parameters, some of which are not very helpful!
63+
64+
# Overlap Requirements
65+
66+
The default in bedder is that a single base of overlap is sufficient to report. However we can add constraints to this with these arguments:
67+
68+
```
69+
-r, --a-requirements <A_REQUIREMENTS>
70+
a-requirements for overlap. A float value < 1 or a number ending with % will be the fraction (or %) of the interval. An integer will be the number of bases. [default: 1]
71+
-R, --b-requirements <B_REQUIREMENTS>
72+
b-requirements for overlap. A float value < 1 or a number ending with % will be the fraction (or %) of the interval. An integer will be the number of bases. [default: 1]
73+
```
74+
75+
Here is the default, requiring a single base of overlap:
76+
77+
```
78+
$ bedder -a tests/examples/aa.bed -b tests/examples/bb.bed -g tests/examples/fake.fai --a-part part --b-part none --a-requirements 1
79+
chr1 8 12
80+
chr1 14 15
81+
chr1 20 23
82+
```
83+
84+
We can update that to require at least 3 bases:
85+
86+
```
87+
$ bedder -a tests/examples/aa.bed -b tests/examples/bb.bed -g tests/examples/fake.fai --a-part whole --b-part whole --a-requirements 3 --a-mode piece
88+
chr1 2 23 chr1 8 12 chr1 20 30
89+
chr1 2 23 chr1 8 12 chr1 20 30 # bug: TODO: printing this line twice
90+
```

tests/examples/fake.fai

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chr1 10000 10000

0 commit comments

Comments
 (0)