<tool id="intersectbed" name="intersectBed">
  <description>intersect two interval sets</description>
  <command> intersectBed -a $inputa -b $inputb $output_opt $strandness $r -f $f $split > $output_data
  </command>
  <inputs>
      <param name="inputa" type="data" format="interval,bam,bed,gff,vcf" label="Input A (-a)"/>
      <param name="inputb" type="data" format="interval,bam,bed,gff,vcf" label="Input B (-b)"/>          
      <param name="output_opt" type="select" label="Output style" >
		<option value="-wa" selected="true"> -wa: entry in A that overlaps B</option>
        <option value="-wb" > -wb: entry in B that overlaps A</option>
        <option value="-wo" > -wo: A,B, and num bases overlap </option>
        <option value="-wao" > -wao: A,B, and num bases overlap </option>
        <option value="-u" > -u: A only </option>
        <option value="-c" > -c: A, num B features overlap </option>
        <option value="-v" > -v: A without overlap </option>
      </param>
  
    <param name="f" size="10" type="float" value="1E-9" label="Minimum overlap required as a fraction of A"/>

      <param name="strandness" type="select" label="Strand requirement" >
		<option value="" selected="true"> none </option>
        <option value="-s" > -s: require overlap on the same strand</option>
        <option value="-S" > -S: require overlap on the opposite strand </option>
      </param>
      
    <param name="r" label="Require that the fraction overlap be reciprocal for A and B (-r)." type="boolean" truevalue="-r" falsevalue="" checked="False"/>
        <param name="split" label="Treat'split' BAM or BED12 entries as distinct BED intervals (-split)." type="boolean" truevalue="-split" falsevalue="" checked="False"/></inputs>
  <outputs>
    <data format="bed" name="output_data"/> 
  </outputs>
  <help>

**What it does**

This is a wrapper for intersecBed.

    Program: intersectBed (v2.13.3)
    Author:  Aaron Quinlan (aaronquinlan@gmail.com)
    Summary: Report overlaps between two feature files.

Usage::

    intersectBed [OPTIONS] -a (bed/gff/vcf) -b (bed/gff/vcf)

Options:: 
	-abam	The A input file is in BAM format.  Output will be BAM as well.

	-ubam	Write uncompressed BAM output. Default is to write compressed BAM.

	-bed	When using BAM input (-abam), write output as BED. The default
		is to write output in BAM when using -abam.

	-wa	Write the original entry in A for each overlap.

	-wb	Write the original entry in B for each overlap.
		- Useful for knowing _what_ A overlaps. Restricted by -f and -r.

	-wo	Write the original A and B entries plus the number of base
		pairs of overlap between the two features.
		- Overlaps restricted by -f and -r.
		  Only A features with overlap are reported.

	-wao	Write the original A and B entries plus the number of base
		pairs of overlap between the two features.
		- Overlapping features restricted by -f and -r.
		  However, A features w/o overlap are also reported
		  with a NULL B feature and overlap = 0.

	-u	Write the original A entry _once_ if _any_ overlaps found in B.
		- In other words, just report the fact >=1 hit was found.
		- Overlaps restricted by -f and -r.

	-c	For each entry in A, report the number of overlaps with B.
		- Reports 0 for A entries that have no overlap with B.
		- Overlaps restricted by -f and -r.

	-v	Only report those entries in A that have _no overlaps_ with B.
		- Similar to "grep -v" (an homage).

	-f	Minimum overlap required as a fraction of A.
		- Default is 1E-9 (i.e., 1bp).
		- FLOAT (e.g. 0.50)

	-r	Require that the fraction overlap be reciprocal for A and B.
		- In other words, if -f is 0.90 and -r is used, this requires
		  that B overlap 90% of A and A _also_ overlaps 90% of B.

	-s	Require same strandedness.  That is, only report hits in B that
		overlap A on the _same_ strand.
		- By default, overlaps are reported without respect to strand.

	-S	Require different strandedness.  That is, only report hits in B that
		overlap A on the _opposite_ strand.
		- By default, overlaps are reported without respect to strand.

	-split	Treat "split" BAM or BED12 entries as distinct BED intervals.

	-sorted	Use the "chromsweep" algorithm for sorted (-k1,1 -k2,2n) input
		NOTE: this will trust, but not enforce that data is sorted. Caveat emptor.

  </help>
</tool>

