Shell script to search one file for contents of another and replace text?
Hi all,
Suppose I have a pair of files containing lists. The first file is called contigs.txt and it contains a list that looks like this: Code:
Contig822 Code:
******************* Code:
GMNVR6W01BC1GA Thanks, Kevin |
And when you use contigs.txt ?
|
Hi,
do you mean something like this Code:
#!/bin/bash |
I am with goosen in that the following does not mention the contigs.txt file anywhere:
Quote:
|
crts, Nailed it! This really helped me out. Thank you. As you guessed, if a Contig# doesn't appear in reads_in_contigs.txt (e.g., Contig826) I want it to remain unchanged in contigs.txt. All of the Contig# names in contigs.txt should have been replaced with the singletons that make them up so if one remained it would serve as a red flag to me that I did something wrong.
grail and goosen, I'm sorry I wasn't very clear on what I was trying to do. If you care, it should have said: "What I want to do is search through the reads_in_contigs.txt file for matches to contig and singleton names in the contigs.txt file and replace contig names (e.g., Contig822) with the singletons that make them up." Does that make more sense? Thanks a lot! Kevin |
Cool ... in that case how about something like:
Code:
awk 'FNR == NR && NF{getline arr[$0];next}{for(x = 1;x <= NF;x++)if($x in arr)print arr[$x];else print $x}' RS="[\n]?[*]+\n" reads_in_contigs.txt contigs.txt |
Hi all,
I'm trying to do something similar to the above but with a twist. Say we have a similar contigs.txt file that looks something like this: Code:
Contig822 Code:
>Contig822 Code:
awk 'FNR == NR && NF{getline arr[$0];next}{for(x = 1;x <= NF;x++)if($x in arr)print ">"arr[$x];else print $x}' RS=">" sequences.txt contigs.txt |
All times are GMT -5. The time now is 03:32 AM. |