Using IDs to extract ID headers and add to second column in file B The 2019 Stack Overflow Developer Survey Results Are Incompare columns in a one file and print the count of matchesRemove entire row in a file if first column is repeatedHow to add a column from a file to the last column of another file using awk?how to change one column and add other columns in a row by awkFind multiple matches in a tabular file and print second column?display lines with not more than 4 words in the second columnHow to get the second column from command output?awk print most common string in second columnColumn manipulation using AWKCompare first and second column of two files and print the row from second file if there is a match
The difference between dialogue marks
What did it mean to "align" a radio?
Can you compress metal and what would be the consequences?
What is the closest word meaning "respect for time / mindful"
Identify boardgame from Big movie
Is there any way to tell whether the shot is going to hit you or not?
Apparent duplicates between Haynes service instructions and MOT
What is the accessibility of a package's `Private` context variables?
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
STM32 programming and BOOT0 pin
Aging parents with no investments
If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?
Earliest use of the term "Galois extension"?
How to save as into a customized destination on macOS?
Have you ever entered Singapore using a different passport or name?
Falsification in Math vs Science
Right tool to dig six foot holes?
How to answer pointed "are you quitting" questioning when I don't want them to suspect
Return to UK after being refused entry years previously
Loose spokes after only a few rides
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
Building a conditional check constraint
Are there any other methods to apply to solving simultaneous equations?
Delete all lines which don't have n characters before delimiter
Using IDs to extract ID headers and add to second column in file B
The 2019 Stack Overflow Developer Survey Results Are Incompare columns in a one file and print the count of matchesRemove entire row in a file if first column is repeatedHow to add a column from a file to the last column of another file using awk?how to change one column and add other columns in a row by awkFind multiple matches in a tabular file and print second column?display lines with not more than 4 words in the second columnHow to get the second column from command output?awk print most common string in second columnColumn manipulation using AWKCompare first and second column of two files and print the row from second file if there is a match
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a file A that contains accession number family name and name and file B that contains ID and sequences.
I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.
Example
File A
NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt
File B
NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Expected Output
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
awk python3
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have a file A that contains accession number family name and name and file B that contains ID and sequences.
I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.
Example
File A
NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt
File B
NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Expected Output
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
awk python3
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have a file A that contains accession number family name and name and file B that contains ID and sequences.
I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.
Example
File A
NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt
File B
NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Expected Output
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
awk python3
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a file A that contains accession number family name and name and file B that contains ID and sequences.
I want to use the accession number in B to retrieve the family name and virus name in A and add it to the second column in B.
Example
File A
NC_001348 PEPS Herpesviridae Human herpesvirus 3, complete genome.txt
NC_001350 PEPS Herpesviridae Saimiriine herpesvirus 2 complete genome.txt
NC_001491 PEPS Herpesviridae Equid herpesvirus 1, complete genome.txt
NC_001798 PEPS Herpesviridae Human herpesvirus 2 strain HG52, complete genome.txt
NC_001806 PEPS Herpesviridae Human herpesvirus 1 strain 17, complete genome.txt
NC_001826 PEPS Herpesviridae Murine herpesvirus 68 strain WUMS, complete genome.txt
NC_001844 PEPS Herpesviridae Equid herpesvirus 4, complete genome.txt
NC_001847 PEPS Herpesviridae Bovine herpesvirus 1, complete genome.txt
NC_001987 PEPS Herpesviridae Ateline herpesvirus 3 complete genome.txt
NC_002229 PEPS Herpesviridae Gallid herpesvirus 2, complete genome.txt
File B
NC_001348_71671_71760_KY215944.1 GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Expected Output
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
awk python3
awk python3
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 days ago
Kusalananda♦
141k17262438
141k17262438
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 days ago
IbkIbk
31
31
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Ibk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Command:
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
output
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too
– Ibk
2 days ago
Will post in python too KIndly upvote my answer
– Praveen Kumar BS
2 days ago
Hi Kumar, its like there is a little glitch.
– Ibk
2 days ago
Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.
– Ibk
2 days ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Ibk is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511295%2fusing-ids-to-extract-id-headers-and-add-to-second-column-in-file-b%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Command:
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
output
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too
– Ibk
2 days ago
Will post in python too KIndly upvote my answer
– Praveen Kumar BS
2 days ago
Hi Kumar, its like there is a little glitch.
– Ibk
2 days ago
Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.
– Ibk
2 days ago
add a comment |
Command:
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
output
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too
– Ibk
2 days ago
Will post in python too KIndly upvote my answer
– Praveen Kumar BS
2 days ago
Hi Kumar, its like there is a little glitch.
– Ibk
2 days ago
Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.
– Ibk
2 days ago
add a comment |
Command:
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
output
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
Command:
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
output
c=`awk 'print NR' file2| sort -nr | sed -n '1p'`;for ((i=1;i<=$c;i++)); do j=`awk -v i="$i" 'NR==i$1=$2="";print $0' file1`; awk -v i="$i" -v j="$j" 'NR == i$3=$2;$2=j;print $0' file2; done| sed "s/complete genome.txt/complete genome/g"
NC_001348_71671_71760_KY215944.1 Herpesviridae Human herpesvirus 3, complete genome GCGCGGCTGGTGATGCAATGCGTGACCAGCTACTGGCGCAACTCGCGCTGCGCCGCCTTTGTGAACAGCTTCCCCATGGTGATGTACATC
NC_001350_89668_89757_HQ221963.1 Herpesviridae Saimiriine herpesvirus 2 complete genome CTTTCAGGATTTTCTGGCAGTTTTGCTGTCAAGAATGACATGATCTGGTGATGCCATATCTCAATATACAGCGCAGTGCTCACTGGTCTG
NC_001491_126502_126591_AF480884.1 Herpesviridae Equid herpesvirus 1, complete genome AACGTGTCGGTGCGCACGGCCGTCAGGGCGAAGCCCGGGTGGATGTGGGCCTTGGTCTGCAGCACCAGCGACACCGGCGAGATCTTGTAC
NC_001798_97563_97652_AY714813.1 Herpesviridae Human herpesvirus 2 strain HG52, complete genome CGCAGGTGCCCGAAGACGTCGCAGACGGCCGCCCGCAGGGCCATGCACTGCATGGAGCCCGTGGTGCCGCCCGGCCCCCGGTCCAGGTGC
NC_001806_196955_197044_FJ483970.2 Herpesviridae Human herpesvirus 1 strain 17, complete genome TCATCGATCTCAGTCTGTCGGCCGCTCCACGGCTCTGACTGGACTTTCCAAAGTACATACTGCAGTCAGAGCTGTCGAGCGGTTAACAGA
answered 2 days ago
Praveen Kumar BSPraveen Kumar BS
1,7641311
1,7641311
Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too
– Ibk
2 days ago
Will post in python too KIndly upvote my answer
– Praveen Kumar BS
2 days ago
Hi Kumar, its like there is a little glitch.
– Ibk
2 days ago
Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.
– Ibk
2 days ago
add a comment |
Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too
– Ibk
2 days ago
Will post in python too KIndly upvote my answer
– Praveen Kumar BS
2 days ago
Hi Kumar, its like there is a little glitch.
– Ibk
2 days ago
Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.
– Ibk
2 days ago
Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too
– Ibk
2 days ago
Thanks Praveen Kumar BS, it works perfectly. I won't mind a python script too
– Ibk
2 days ago
Will post in python too KIndly upvote my answer
– Praveen Kumar BS
2 days ago
Will post in python too KIndly upvote my answer
– Praveen Kumar BS
2 days ago
Hi Kumar, its like there is a little glitch.
– Ibk
2 days ago
Hi Kumar, its like there is a little glitch.
– Ibk
2 days ago
Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.
– Ibk
2 days ago
Hi Kumar, Its like there is a little glitch. File A and B are not perfect match. The first nine characters of each line in File B are supposed to run through file A which are unique, then return the name of the accession number after PEPS and add it as second column to file B to form a new file.
– Ibk
2 days ago
add a comment |
Ibk is a new contributor. Be nice, and check out our Code of Conduct.
Ibk is a new contributor. Be nice, and check out our Code of Conduct.
Ibk is a new contributor. Be nice, and check out our Code of Conduct.
Ibk is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511295%2fusing-ids-to-extract-id-headers-and-add-to-second-column-in-file-b%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
-awk, python3