-4

I have this header:

>tr|G3Q381|G3Q381_GASAC Uncharacterized protein OS=Gasterosteus aculeatus PE=4 SV=1

and I was thankfully helped on here to get it to:

 >G3Q381_GASAC

but now I need to cut the last two letters off of the previous format like this:

  >G3Q381_GAS

Is it possible from the initial long header (not middle truncated one) to get it to this?

closed as unclear what you're asking by jasonwryan, muru, jordanm, Anthon, jimmij Feb 26 '15 at 19:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • This question is unclear to me. Is this only one header or more with similar pattern? If only one then just write echo '>G3Q381_GAS' and you are done. If there are more headers then show us more of them catch similarities. Remember that sed or other text processing tool works on regular expressions, i.e. there must be some regularities. – jimmij Feb 26 '15 at 14:00
  • You are right, I apologize. After the header there are 4 more lines. I just want to change the header of these sequences while keeping the carrot. There are many more lines with this header following the same pattern – derb2k Feb 26 '15 at 14:04
  • This is unanswerable in its current form as it presumes a middle step that is not documented, ie., how you arrive at the current (truncated) header. Voting to close as unclear. – jasonwryan Feb 26 '15 at 16:00
0

I don't know if it acceptable, but you can remove everything before the second pipe |, and everything after the first space minus 2 characters :

sed -e 's/^[^|]*|/>/' -e 's/^[^|]*|/>/' -e 's/.. .*$//'
  • No it doesn't unfortunately. It actually deletes the lines after the header even though it does delete the last two characters. |I3KMH5|I3KMH5_ORE Plus I need the carrot '>' there – derb2k Feb 26 '15 at 13:55
  • I edited it, it should do what you want now – Corentin Peuvrel Feb 26 '15 at 14:05
  • okay i'll check. Thank you for the rapidity – derb2k Feb 26 '15 at 14:06
  • Thank you sir this worked. Thanks. Soon I will read up on Sed and not have to bother you guys. – derb2k Feb 26 '15 at 14:07
  • i was trying to upvote it but it says I don't yet have the reputation – derb2k Feb 26 '15 at 14:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.