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 8272901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:17:13+00:00 2026-06-08T07:17:13+00:00

So I have file with about thousand line that look like this: COADREAD ZNF271

  • 0

So I have file with about thousand line that look like this:

COADREAD    ZNF271  Missense_Mutation   TCGA-AA-3947    Q14591  A177T 
COADREAD    ZNF271  Missense_Mutation   TCGA-AA-A00N    Q14591  I26T  
COADREAD    ZNF271  Missense_Mutation   TCGA-AG-A002    Q14591  M418T

I have code that look for 5th column for the id and grab the number between two letter.

Is there a way that I can also grab whole token after id in 5th column (or column 6th token).

I want to grab that token so I can write it on to another file.

Here is what I have so far( This code will give me number, but is there way to get both number to calculate and whole string of that token to print on to the output file):
For example, if I call lookup[Q14591] it give me [‘177′,’26’,418] but I also want A177T I26T and M418T

lookup = defaultdict(list)
mydata = open('summaryfile.txt')
for line in csv.reader(mydata, delimiter='\t'):
    code = re.match('[a-z](\d+)[a-z]', line[-1], re.I)
    if code: 
        lookup[line[-2]].append(code.group(1))
  • 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-08T07:17:16+00:00Added an answer on June 8, 2026 at 7:17 am

    When using regular expressions, group(0) should contain the whole matched string. So in your case:

    code.group(0)
    

    should contain the whole token. So if you modify your code to look like this:

    lookup = defaultdict(list)
    wholelookup = defaultdict(list)
    
    mydata = open('summaryfile.txt')
    for line in csv.reader(mydata, delimiter='\t'):
        code = re.match('[a-z](\d+)[a-z]', line[-1], re.I)
        if code: 
            lookup[line[-2]].append(code.group(1))
            wholelookup[line[-2]].append(code.group(0))
    

    Then you can access whole tokens like this:

    wholelookup['Q14591']
    

    or the sub-tokens like this:

    lookup['Q14591']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that reads a huge text file (about more than 100MB)
I have a batch file that installs WinVNC in about 1 second and starts
I have a PHP file that contains a large array (about 90KB). I'm considering
I have always wondered about this. So many application setups have a zip file
I have two perforce clients (client-a, client-b) that each contain about 40 file specs.
I have some lines in a CSV file like this: 1000001234,Account Name,0,0,3,711.32,0,0,18,629.64,22,340.96,COD,20,000.00,Some string,Some string
I have a file that has over 200 lines in this format: name old_id
I have a file with about a couple thousand entries in the form timestamp
I have a bash script file which starts with a function definition, like this:
I have a file of about 19500+ lines of code. I am doing work

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.