This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Exacting lines containing Id from one file from ID from other file.

Hellow,

I want to extract the lines containing ID from my GFF file using ID fom other file.

My GFF file:

st00    PGSC0003DMC400069336    5046482 5046991
st00    PGSC0003DMC400069337    35003649    35012075
st00    PGSC0003DMC400069343    7843951 7845166
st00    PGSC0003DMC400069373    9133414 9134204
st00    PGSC0003DMC400069455    5268379 5270012
st1 PGSC0003DMC400000001    71267700    71268573
st1 PGSC0003DMC400000002    71267700    71269327
st1 PGSC0003DMC400000003    71268310    71268573
st1 PGSC0003DMC400000004    71271492    71272645

File containing IDs:

PGSC0003DMC400001685
PGSC0003DMC400001686
PGSC0003DMC400004210
PGSC0003DMC400004304
PGSC0003DMC400004305
PGSC0003DMC400004307
PGSC0003DMC400004308
PGSC0003DMC400004309
PGSC0003DMC400004310
PGSC0003DMC400005061
PGSC0003DMC400005062
PGSC0003DMC400005063

I have tried using various command:

ruby -pe 'File.open("blastid.txt").each { |i| puts i if i =~ /\$_/ }' uniqueCDS.txt > finaltry.txt

awk -F '\t' 'NR==FNR {id[$1]; next} $1 in id' blastid.txt uniqueCDS.txt

xargs -I {} grep "^{}" uniqueCDS.txt < blastid.txt

But nothing is working.

I need help

Thank you

extracting line id

Unless you show us the code how can we tell you why it is not working.

Sorry, I have tried join by using this command:

join -t$'\t' <(sort -d blastid.txt) <(sort -d -t$'\t' -k2,1 uniqueCDS.txt) > output.txt

but my output is:

join: /dev/fd/62:13435: is not sorted: st1 PGSC0003DMC400000001 71267700 71268573

2 answers

try

join -t $'\t' -1 1 -2 2 <(sort -k1,1 blastid.txt) <(sort  -t $'\t' -k2,2 uniqueCDS.txt) > output.txt

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.

Upvote|Bookmark|Accept

$ grep -wFf ids.txt annotations.gff > answer.txt

Log in to answer this question.