Entering edit mode
11.9 years ago
macmath
▴
170
I am trying to substitute the FILE 2 containing the >o387128170 to respective >MJ from FILE 1
File1 *tab separated file*
MJ o387128170
NH s292492417
PA t253987822
PS m392982075
RB b91205976
RG RG01000991
File2
>o387128170
MPRRRVVAKREVLPDPKYANIGLAKFINVIMKDGKKSVAEKITYGALASVSENKGGNGLE
>s292492417
MPRKRVITGREVLPDPKYGSAQLAKFITILMLNGKKSLAEKIVYGALDRAAEKANQEPMD
>t253987822
MPRRRVIGQRKILPDPKFGSELLAKFVNILMVDGKKSTAEAIVYSALETLAQRSGKEHLE
>m392982075
MPRRRVAAKREVLADPKYGSQILAKFMNHVMESGKKAVAERIVYGALDKVKERGKADPLE
>b91205976
MSRRHAAEKRVILPDMKYNSVLLSRFINNIMKEGKKALAEKIVYSAFDKIEKKHKADPYQ
>RG01000991
MKNGKKAVAEKIVYGALEWLNLRLKEKSKKAEGASGENNQNKQQDLDAATLLDVFDQALD
Expected Output file:
>MJ
MPRRRVVAKREVLPDPKYANIGLAKFINVIMKDGKKSVAEKITYGALASVSENKGGNGLE
>NH
MPRKRVITGREVLPDPKYGSAQLAKFITILMLNGKKSLAEKIVYGALDRAAEKANQEPMD
>PA
MPRRRVIGQRKILPDPKFGSELLAKFVNILMVDGKKSTAEAIVYSALETLAQRSGKEHLE
>PS
MPRRRVAAKREVLADPKYGSQILAKFMNHVMESGKKAVAERIVYGALDKVKERGKADPLE
>RB
MSRRHAAEKRVILPDMKYNSVLLSRFINNIMKEGKKALAEKIVYSAFDKIEKKHKADPYQ
>RG
MKNGKKAVAEKIVYGALEWLNLRLKEKSKKAEGASGENNQNKQQDLDAATLLDVFDQALD
Because both have different approach to get the needful... In this case I need the fasta files address lines changed by the tabulated one and in the other post is the change in the nexus file
I will surely try to make effort for proper indenting in the question
But the approach is exactly the same for both problems - as you indicated yourself with the tags awk, grep, sed. You should also indicate what you have tried already. Anyway - we will leave both questions for now and see what other users say.
Command line stuff are great, but why try to squeeze complex functions out of them when you can use an expressive scripting language (python/perl) and accomplish the same thing in probably a similar amount of time. I would sit down and learn how to script with python or perl so you don't have to keep asking people to help you with these pretty simple data manipulation tasks. These tasks are actually perfect for learning.
This kind of stuff does not need to use python/perl since it is a stream edition which to be done with something like sed/awk. In bioinformatics and computer sciences, I believe that you need to choose the best langage adapted for your task. Do not need to take a canon to kill a fly!
It depends on the problem you are trying to solve and your familiarity with whatever method you choose to use. I agree that this is a pretty simple manipulation problem and can be done with command line functions.
However, I feel like there is a trend of people who try to solve all their problems with command line functions. It becomes more of a code-golf exercise where you spend your time generating an elegant single liner rather than just solving the problem at hand. I am guilty of that from time to time.
For beginners, command line can also sometimes become a crutch or an excuse not to learn scripting.
I am sorry but awk is a programming langage as perl/python and not a command line function. It can be called on a command line like perl can.