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

  • SEARCH
  • Home
  • 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 9122255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:03:34+00:00 2026-06-17T06:03:34+00:00

I have a table like this: symbol refseq seqname start stop strand Susd4 NM_144796

  • 0

I have a table like this:

symbol  refseq          seqname start           stop            strand
Susd4   NM_144796       chr1    184695027       184826500       +
Ptpn14  NM_008976       chr1    191552147       191700574       +
Cd34    NM_001111059    chr1    196765080       196787475       +
Gm5698  NM_001166637    chr1    31034088        31055753        -
Epha4   NM_007936       chr1    77363760        77511663        -
Sp110   NM_175397       chr1    87473474        87495392        -
Gbx2                    chr1    91824537        91827751        -
Kif1a                   chr1    94914855        94998430        -
Bcl2    NM_009741       chr1    108434770       108610879       -

And I want to extract data with the following conditions:

1) lines that the values in “refseq” column are not missing

2) for the values in the columns “start” and “stop“, only keep one value for each line: if the value in the column “strand” is “+“, take the value in “start“; if the value in the column “strand” is “-“, take the value in “stop“.

And this is what expected:

Susd4   NM_144796   chr1    184695027   +
Ptpn14  NM_008976   chr1    191552147       +
Cd34    NM_001111059    chr1    196765080       +
Gm5698  NM_001166637    chr1        31055753    -
Epha4   NM_007936   chr1        77511663    -
Sp110   NM_175397   chr1        87495392    -
Bcl2    NM_009741   chr1        108610879   -
  • 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-17T06:03:36+00:00Added an answer on June 17, 2026 at 6:03 am

    I would be very tempted to leave the input delimiter unmodified so blanks and tabs separate fields, rather than insisting on tabs only. That means you want records after the first (to skip the headings line) that have six fields:

    awk 'NR > 1 && NF == 6 { if ($6 == "+") x = $4; else x = $5; print $1, $2, $3, x; }'
    

    If you want to control the output format more, you can dink with OFS, or use printf:

    awk 'BEGIN { OFS = "\t" }
         NR > 1 && NF == 6 { if ($6 == "+") x = $4; else x = $5; print $1, $2, $3, x; }'
    
    awk 'NR > 1 && NF == 6 { if ($6 == "+") x = $4; else x = $5;
                             printf "%-8s %-12s %s %9s\n", $1, $2, $3, x; }'
    

    There are other ways to handle it, I’m sure…

    The first script produces:

    Susd4 NM_144796 chr1 184695027
    Ptpn14 NM_008976 chr1 191552147
    Cd34 NM_001111059 chr1 196765080
    Gm5698 NM_001166637 chr1 31055753
    Epha4 NM_007936 chr1 77511663
    Sp110 NM_175397 chr1 87495392
    Bcl2 NM_009741 chr1 108610879
    

    The content is correct, I believe; the formatting can be improved in many ways. The last script produces:

    Susd4    NM_144796    chr1 184695027
    Ptpn14   NM_008976    chr1 191552147
    Cd34     NM_001111059 chr1 196765080
    Gm5698   NM_001166637 chr1  31055753
    Epha4    NM_007936    chr1  77511663
    Sp110    NM_175397    chr1  87495392
    Bcl2     NM_009741    chr1 108610879
    

    You can tweak field widths as necessary.

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

Sidebar

Related Questions

I have table in an MS Access database that looks like this: ID Symbol
I have table like this : ID Name_1 Name_2 Name_3 1 Egon Spengler Ives
I have a table like this ID Name IsDeleted 1 Yogesh Null 2 Goldy
I have a table like this : +-------+------------+------+-----+---------+-------+ | Field | Type | Null
I have a table like this: ID country ------------- 1 US 2 Japan 3
I have a table like this: id | id_parent | tag_name 0 | |
I have a table like this: CREATE TABLE book_info ( book_id VARCHAR(32) not null,
I have a table like this: <table> <tr> <td> A-1 </td> <td> A-2 </td>
I have UserComments table like this : 1 | Frank | hello world 2
I have a table like this gems ---------- id, color 1 , green 2

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.