Source code

Download source archive ↓

upstream-extended/iuc/tools/bedtools/mergeBed.xml

1<tool id="bedtools_mergebed" name="bedtools MergeBED" version="@TOOL_VERSION@+galaxy2" profile="@PROFILE@">
2    <description>combine overlapping/nearby intervals into a single interval</description>
3    <macros>
4        <import>macros.xml</import>
5    </macros>
6    <expand macro="bio_tools" />
7    <expand macro="requirements" />
8    <expand macro="stdio" />
9    <command><![CDATA[
10mergeBed
11-i '${input}'
12$strand
13-d $distance
14$header
15@C_AND_O_ARGUMENT@
16#if $input.ext == "bam"
17    -bed
18#end if
19> '${output}'
20    ]]></command>
21    <inputs>
22        <param  name="input" argument="-i" type="data" format="bam,@STD_BEDTOOLS_INPUTS@" label="Merge the following BAM/@STD_BEDTOOLS_INPUT_LABEL@ file"/>
23        <param name="strand" type="select" label="Calculation based on strandedness?">
24            <option value="" selected="true">Overlaps on either strand</option>
25            <option value="-s">Force strandedness. That is, only merge features that are the same strand (-s)</option>
26            <option value="-S +">Force merge for forward strand only (-S +)</option>
27            <option value="-S -">Force merge for reverse strand only (-S -)</option>
28        </param>
29        <param name="distance" argument="-d" type="integer" value="0"
30            label="Maximum distance between features allowed for features to be merged"
31            help="Default 0: overlapping and/or book-ended features are merged. Note: negative values enforce the number of b.p. required for overlap."/>
32        <expand macro="print_header" />
33        <expand macro="c_and_o_argument">
34            <param name="col" argument="-c" type="data_column" data_ref="input" label="Specify the column(s) that should be summarized" />
35        </expand>
36    </inputs>
37    <outputs>
38        <data name="output" format="bed" metadata_source="input" label="Merged ${input.name}"/>
39    </outputs>
40    <tests>
41        <test>
42            <param name="input" value="mergedBed1.bed" ftype="bed" />
43            <output name="output" file="mergedBed_result1.bed" ftype="bed" />
44            <assert_command>
45                <not_has_text text="-s "/>
46                <not_has_text text="-S "/>
47                <has_text text="-d 0"/>
48                <not_has_text text="-c "/>
49                <not_has_text text="-o "/>
50            </assert_command>
51        </test>
52        <test>
53            <param name="input" value="mergedBed2.bed" ftype="bed" />
54            <param name="strand" value="-s" />
55            <output name="output" file="mergedBed_result2.bed" ftype="bed" />
56            <assert_command>
57                <has_text text="-s "/>
58                <not_has_text text="-S "/>
59                <has_text text="-d 0"/>
60                <not_has_text text="-c "/>
61                <not_has_text text="-o "/>
62            </assert_command>
63        </test>
64        <test>
65            <param name="input" value="mergedBed3.bed" ftype="bed" />
66            <output name="output" file="mergedBed_result3.bed" ftype="bed" />
67            <assert_command>
68                <not_has_text text="-s "/>
69                <not_has_text text="-S "/>
70                <has_text text="-d 0"/>
71                <not_has_text text="-c "/>
72                <not_has_text text="-o "/>
73            </assert_command>
74        </test>
75        <test>
76            <param name="input" value="mergedBed4.bed" ftype="bed" />
77            <param name="distance" value="1000" />
78            <output name="output" file="mergedBed_result4.bed" ftype="bed" />
79            <assert_command>
80                <not_has_text text="-s "/>
81                <not_has_text text="-S "/>
82                <has_text text="-d 1000"/>
83                <not_has_text text="-c "/>
84                <not_has_text text="-o "/>
85            </assert_command>
86        </test>
87        <test>
88            <param name="input" value="mergedBed4.bed" ftype="bed" />
89            <param name="distance" value="1000" />
90            <repeat name="c_and_o_argument_repeat">
91                <param name="col" value="1"/>
92                <param name="operation" value="count"/>
93            </repeat>
94            <output name="output" file="mergedBed_result5.bed" ftype="bed" />
95            <assert_command>
96                <not_has_text text="-s "/>
97                <not_has_text text="-S "/>
98                <has_text text="-d 1000"/>
99                <has_text text="-c 1"/>
100                <has_text text="-o count"/>
101            </assert_command>
102        </test>
103    </tests>
104    <help><![CDATA[
105**What it does**
106
107bedtools merge combines overlapping or "book-ended" features in an interval file into a single feature which spans all of the combined features.
108
109
110.. image:: $PATH_TO_IMAGES/merge-glyph.png
111
112
113.. class:: warningmark
114
115bedtools merge requires that you presort your data by chromosome and then by start position.
116
117
118==========================================================================
119Default behavior
120==========================================================================
121By default, ``bedtools merge`` combines overlapping (by at least 1 bp) and/or
122bookended intervals into a single, "flattened" or "merged" interval.
123
124::
125
126  $ cat A.bed
127  chr1  100  200
128  chr1  180  250
129  chr1  250  500
130  chr1  501  1000
131
132  $ bedtools merge -i A.bed
133  chr1  100  500
134  chr1  501  1000
135
136
137==========================================================================
138*-s* Enforcing "strandedness"
139==========================================================================
140The ``-s`` option will only merge intervals that are overlapping/bookended
141*and* are on the same strand.
142
143::
144
145  $ cat A.bed
146  chr1  100  200   a1  1 +
147  chr1  180  250   a2  2 +
148  chr1  250  500   a3  3 -
149  chr1  501  1000  a4  4 +
150
151  $ bedtools merge -i A.bed -s
152  chr1  100  250    +
153  chr1  501  1000   +
154  chr1  250  500    -
155
156
157==========================================================================
158*-d* Controlling how close two features must be in order to merge
159==========================================================================
160By default, only overlapping or book-ended features are combined into a new
161feature. However, one can force ``merge`` to combine more distant features
162with the ``-d`` option. For example, were one to set ``-d`` to 1000, any
163features that overlap or are within 1000 base pairs of one another will be
164combined.
165
166::
167
168  $ cat A.bed
169  chr1  100  200
170  chr1  501  1000
171
172  $ bedtools merge -i A.bed
173  chr1  100  200
174  chr1  501  1000
175
176  $ bedtools merge -i A.bed -d 1000
177  chr1  100  200  1000
178
179
180@REFERENCES@
181    ]]></help>
182    <expand macro="citations" />
183</tool>