Remove some IDs from IDs list
3
0
Entering edit mode
6.5 years ago
Janey ▴ 30

Hi

I have 40000 IDs in txt file related to redundant contigs . I want to remove these IDs from main IDs list in txt file. like these:

I have two txt files.

1- Main IDs (150000 IDs) txt file

2- IDs that require to remove from main IDs list (40000 IDs) txt file

Thanks for your help

RNA-Seq • 1.9k views
ADD COMMENT
2
Entering edit mode
6.5 years ago

Hello Janey,

cat main.txt remove.txt|sort|uniq -u

should do it.

fin swimmer

ADD COMMENT
0
Entering edit mode

Hi finswimmer

Your command worked great

Thanks

ADD REPLY
0
Entering edit mode

Fine if this was helpful.

You should upvote posts that you find helpful and/or mark those as accepted which solve your problem. shenwei356 solution together with cpad0112 comment work's also fine and is probably the faster method. So you should upvote those posts as well.

enter image description here

Now we can go on investigating your initial problem?

fin swimmer

ADD REPLY
0
Entering edit mode

Hi finswimmer

Because my unix system is very specific, so among all the suggestions of my previous posts, your command was only useful. It was completely compatible with my unix system. Can you suggest the same kind of command for filtering sequences by IDs from fasta files.

thanks

ADD REPLY
0
Entering edit mode

Hello Janey,

what is that special in your unix system?

You already have started a thread about FASTA filtering. Have you tried what cpad0112 suggested? Did you have a look at the links Pierre posted?

If nothing of this helps please answer in that thread what is meant by "doesn't work". This helps to keep the focus of the discussion to the corresponding thread title.

fin swimmer

ADD REPLY
4
Entering edit mode
6.5 years ago

You need learn some basic shell commands, like grep.

You need this for this post:

grep -v -f small.txt big.txt > big-small.txt

And what's the most important, try provide enough information when asking problem. Providing some sample data can save you and us a lot of time.

I guess you are continue trying to solve the same problem posted in Fasta file filtering and Remove sequence from fasta file by samtools . Please post several lines of your sequence and ID list files.

ADD COMMENT
2
Entering edit mode

Taking one day to learn some shell knowledge can save you much time.

Finding Things: http://swcarpentry.github.io/shell-novice/07-find/index.html

ADD REPLY
1
Entering edit mode

@Janey: please add -w to be on safe side.

ADD REPLY
0
Entering edit mode

Yes, your solution is more beautiful than mine :)

ADD REPLY
1
Entering edit mode

Not so sure. grep -f can be very very slow. This can be easily done with cat or awk

ADD REPLY
1
Entering edit mode
6.5 years ago

One can use 'join' and 'comm'. -v option in join gives incomparable items from the column of choosen file. In example, files are sorted. in general, it is better to join on sorted files.

For eg.

input long_ids.txt:

$ cat long_ids.txt 
a
b
c
d
e
f
g
h

input short_ids.txt:

$ cat short_ids.txt 
a
b
c
d

output:

$ join -v 1  -1 1 -2 1 long_ids.txt short_ids.txt 
e
f
g
h
ADD COMMENT
0
Entering edit mode

I think diff would be the best tool for this case

ADD REPLY
0
Entering edit mode

There is an unlimited number of ways of doing it.

ADD REPLY

Login before adding your answer.

Traffic: 2250 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