Bedtools intersect a position in a range
1
0
Entering edit mode
6.4 years ago

I used an answer from this post (C: How To Intersect A Range With Single Positions) to intersect a specific position within a range. Specifically I used:

awk 'BEGIN{OFS="\t"} {print $1, $2-1,$2, $3, $4, $5, $6, $7, $8, $9, $10}' Nonsensetranslated.txt \ | intersectBed -a - -b final_starts_stops.bed -wa -wb > done.txt

It printed to the screen well, however when I tried to output it to a file, it failed and kept giving me this as an error:

awk: can't open file  

 input record number 15577, file  

 source line number 1

I don't quite know where I could be going wrong. Any suggestions? 

Here are some examples of what my files look like:

Nonsensetranslated.txt:

chr22    43089485    -    A4GALT    NM_017436.4    158    TGG    W    TAG    *
chr22    43089175    -    A4GALT    NM_017436.4    261    TGG    W    TGA    *
chr12    53702241    -    AAAS    NM_015665.5    387    CAG    Q    TAG    *
chr12    53708891    -    AAAS    NM_015665.5    145    CAA    Q    TAA    *
chr12    53703486    -    AAAS    NM_015665.5    237    CAA    Q    TAA    *
chr12    53701679    -    AAAS    NM_015665.5    456    CAG    Q    TAG    *
chr12    53708083    -    AAAS    NM_015665.5    230    CGA    R    TGA    *
chr12    53703020    -    AAAS    NM_015665.5    286    CGA    R    TGA    *
chr12    53702572    -    AAAS    NM_015665.5    342    CGA    R    TGA    *
chr12    53701482    -    AAAS    NM_015665.5    478    CGA    R    TGA    *

final_starts_stops.bed:

chr12    9220303    9268558
chr1    76190031    76229363
chr12    121163570    121177811
chr17    7123149    7128586
chr11    107992257    108018891
chr12    52301201    52317145

 

 

bedtools intersect • 1.8k views
ADD COMMENT
0
Entering edit mode

"tried to output it to a file" - what do you mean by that (you already did this with > done.txt)? Output awk or bedtools? Can you post your command?

ADD REPLY
0
Entering edit mode

Yes, but when I tried > done.txt at the end of my original code, I got the error. I can print it to the screen fine without the > done.txt

 

ADD REPLY
2
Entering edit mode
6.4 years ago
iraun ★ 3.8k

Try removing "\" symbol. I tried your command and for me works nice, both on screen and on file, so, it's a bit weird :S.

ADD COMMENT
0
Entering edit mode

Perfect! Thank you soo much :)

ADD REPLY

Login before adding your answer.

Traffic: 1922 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6