mercredi 4 novembre 2015

Splitting a `.bed` file based on chromosomes into `chromosomeName.bed` with perl

I am trying to use perl to split a .bed file into multiple ones based on chromosome. For example, my input file is example.bed:

chr1    12190   12227
chr1    12595   12721
chr2    876522  876688
chr2    887378  887521
...

And my ideal output is two .bed files:

chr1.bed

chr1    12190   12227
chr1    12595   12721

chr2.bed

chr2    876522  876688
chr2    887378  887521

I know using awk to do this is easier, but I am hoping to figure out how to do this using a perl script.

Aucun commentaire:

Enregistrer un commentaire