SEQanswers (
-   Bioinformatics (
-   -   Splitting a bed file in multiple bed files by track (

albireo 05-20-2013 03:35 AM

Splitting a bed file in multiple bed files by track

I have a large combined bed files with several tracks (peaks called for several experiments) of the form

track name="track name 1" description="description1" visibility=2
chr1 1580180 1580696 3 12
chr1 1645419 1645941 4 19
chr1 1700177 1700614 5 10
track name="track name 2" description="description1" visibility=2


is there a quick way to split this file into multiple beds (one for eack track)?

Thanks a lot for your help

GenoMax 05-20-2013 07:50 AM

See if this works.


awk '/^track/{x="Track"++i".bed";}{print > x;}' your_bed_file
This should produce multiple files (one for each track) with names like "Track1.bed Track2.bed" etc. Modify the word highlighted in red to get corresponding file names.

albireo 05-21-2013 05:51 AM

works like a charm thanks a lot!!

zgtmann 12-18-2014 12:58 PM

awk '{print $0 >> $1".bed"}' in_bed

All times are GMT -8. The time now is 07:15 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.