replacing values in a bed file
0
0
Entering edit mode
5.9 years ago

This is a bed file which is generated from a bam file

ChrM 3259 3900 +


and i have analysis bed file where i want to change the start and end column values acoording to the bed file co-ordinates so that i can do the furthere analysis

#chr start end diseases
chrM 1    1       xyz
chrM 2    2       xyz
chrM 3    3       xyz
chrM 4   4      xyz
chrM 5    5       xyz


Here I want to replace the start and end column values which are like 1 to 641 so here i want to make 1 is replaced by 3259 and onwards

Expected output should look like this

#chr start end diseases
chrM 3259 3259     xyz
chrM 3260 3260      xyz
chrM 3261 3261   xyz
chrM 3262 3262     xyz
.
.
chrM 3900  3900      xyz


help me thank you in advance

genome bed • 1.8k views
1
Entering edit mode

Please rephrase your question so it is clearer what you want. And avoid SMS jargon in online forums - avoiding SMS jargon is an indicator that you take what you do seriously.

Some information you may want to add:

1. What information does the second column in the second BED file give you? Would it be any different if it were to have 10 in there instead of 1?
2. Is column#3 in BED file 2 always 1 more than column #2? What effect does the difference have on the operation?
3. Where is the vcf you speak of in the title in all this?

Honestly though, this is pure text processing and is not strictly bioinformatics.

0
Entering edit mode

ok ram sir , where i can find the answer

1
Entering edit mode

Your question is still unclear. If you don't know the answer to the questions I've asked and I'm asking now, you should take a good look at your scientific problem again, consult with your colleagues and ensure you are on the right track.

• 3259+840 is not 3900, so what significance does the 840 number hold?
• What are these two BED files? "Analysis" is the most generic term you can use here, so that's of no use.
• Why are you trying to do what you're trying to do?
1
Entering edit mode

@kapil, Instead of using 'analysis bed file' or 'non-analysis bed file' etc, explain in easy terms. For instance,

A.bed contains this.., B.bed contains this..and the expected output would be this..and I have tried this..

It would be easy to understand the problem you are facing.

0
Entering edit mode

I still can't understand what it is that you are asking (if the version above is one after clarification).

0
Entering edit mode

@kapil's ISP probably charges him by the character so the SMS jargon :-)

0
Entering edit mode

can u please check now sir

1
Entering edit mode

I think I have understood what @kapil wants.

If your columns are space separated then the following should work

awk '{OFS=" "; print $1,($2+3258),($3+3258),$4}' your_file > new_file


otherwise adjust the input/output separator as needed.

awk -F 'your_separator' '{OFS=" "; print $1,($2+3258),($3+3258),$4}' your_file > new_file