Question: change ".." to tab or change a string of characters into different column
0
gravatar for Ming Lu
2.3 years ago by
Ming Lu10
Australia
Ming Lu10 wrote:

I want to change a CTCF CHIA-PET bed file data to its two end bed file. how can I change

       chrX:154145949..154146870-chrX:154314445..154315402,2
       chrX:154208778..154209800-chrX:154376894..154377812,3
       chrX:154208831..154209797-chrX:154285357..154286294,4

into

      chrX 154145949 154146870
      chrX 154314445 154315402
      chrX 154208778 154209800
      chrX 154376894 154377812
      chrX 154208831 154209797
      chrX 154285357 154286294
chip-seq • 524 views
ADD COMMENTlink modified 2.3 years ago by cpad011212k • written 2.3 years ago by Ming Lu10
1
gravatar for Puli Chandramouli Reddy
2.3 years ago by
Pune, India
Puli Chandramouli Reddy180 wrote:

Hi,

Use this

sed 's/-/\n/g;s/:/\t/g;s/\.\./\t/g;s/,[0-9]//g' ./your_file > ./your_file_mod
ADD COMMENTlink written 2.3 years ago by Puli Chandramouli Reddy180
1
gravatar for Alex Reynolds
2.3 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:

To create an unsorted BED file:

$ awk -v OFS="\t" '{n=split($0, a, /[:.\-,]/); printf("%s\t%s\t%s\n%s\t%s\t%s\n", a[1],a[2],a[4],a[5],a[6],a[8]);}' chia-pet.txt > chia-pet.unsorted.bed

To create a sorted BED file:

$ awk -v OFS="\t" '{n=split($0, a, /[:.\-,]/); printf("%s\t%s\t%s\n%s\t%s\t%s\n", a[1],a[2],a[4],a[5],a[6],a[8]);}' chia-pet.txt | sort-bed - > chia-pet.bed

Sorted BED files allow BEDOPS binaries to do set operations on BED files correctly and efficiently.

ADD COMMENTlink modified 2.3 years ago • written 2.3 years ago by Alex Reynolds29k
1
gravatar for cpad0112
2.3 years ago by
cpad011212k
India
cpad011212k wrote:

output:

$ awk -v OFS="\t" '{gsub("-","\n"); gsub(/:|\../," ")}1' test.txt | sed 's/,.*//g' or $ sed 's/,.*//g' test.txt | tr ":" " " | tr ".." " " | tr "-" "\n"

chrX 154145949 154146870
chrX 154314445 154315402
chrX 154208778 154209800
chrX 154376894 154377812
chrX 154208831 154209797
chrX 154285357 154286294

input:

$ cat test.txt 
chrX:154145949..154146870-chrX:154314445..154315402,2
chrX:154208778..154209800-chrX:154376894..154377812,3
chrX:154208831..154209797-chrX:154285357..154286294,4
ADD COMMENTlink modified 2.3 years ago • written 2.3 years ago by cpad011212k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1472 users visited in the last hour