Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:33:57+00:00 2026-06-05T06:33:57+00:00

First post here and it’s and awk question. I have a file that looks

  • 0

First post here and it’s and awk question.

I have a file that looks like this:

Motif name class from to strand sequence score
>ENSBTAG00000000436                         
MA0079.2 SP1 Zinc-coordinating 29 38 - agggggtggg 6.33
... (50 similar lines)
>ENSBTAG00000000380                         
MA0113.1 NR3C1 Zinc-coordinating 92 109 - ccagaaagtgcttctccc 7.03
... (57 similar lines)

and so on. Note that the >ENSBTA line is a ‘label’ for a set of records. So what I’d like is for the >ENSBTA line to be appended as a field in the lines beginning MA… i.e.

MA0079.2 SP1 Zinc-coordinating 29 38 - agggggtggg 6.33 >ENSBTAG00000000436

So far I have

awk '{if (NR>1&&NF==1) genename=$1; if (NR>1&&NF>1) print $0, genename}'

Which is quite close but it doesn’t keep the ENST identifiers with the right lines. So referring to the example above not all 57 lines of the second part of the file get the correct identifier (ENSBTAG00000000380).

Could someone please suggest the best way to go about this?

Thanks

Iain

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:33:58+00:00Added an answer on June 5, 2026 at 6:33 am

    Not tested, but something like this ought to be close to what you want:

    awk '/^>ENSBTAG/{tag=$0;}/^MA/{print $0,tag}'
    

    That says essentially if the line matches “>ENSBTAG” at the beginning of the line, save that line in a variable, but if it matches “MA” at the beginning of the line, print the line with the latest tag appended.

    If your record lines don’t always match “^MA” (all the ones in the example do, but I don’t want to assume that), or if the tags sometimes look a bit different, you’ll need to modify the regexps accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first post here so kindly pardon any mistakes that I have.
This is my first post here. I have been reading posts here since I
This is my first post here. I have a problem. I need to take
first post here at this great website! I would like to reduce the amount
This is my first post here. I want to check if a file exists
this is my first post here. I need create a feed like facebook with
As this is my first post here, I would like to thank all of
this is my first post here and i like to thank all the people
that's my first post here. I have problem with managing activities. I have my
My first post here! Seems like this is the place to get wise ;)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.