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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:42:05+00:00 2026-05-14T04:42:05+00:00

My Friends, I spent quite some time on this one… but cannot yet figure

  • 0

My Friends,

I spent quite some time on this one… but cannot yet figure out a better way to do it. I am coding in python, by the way.

So, here is a line of text in a file I am working with, for example:

“>ref|ZP_01631227.1| 3-dehydroquinate synthase [Nodularia spumigena CCY9414]…”

How can I extract the two strings “ZP_01631227.1” and “Nodularia spumigena CCY9414” from the line?

The pairs of “| |” and brackets are like markers so we know we want to get the strings in between the two…

I guess I can probably loop over all the characters in the line and do it the hard way. It just takes so much time… Wondering if there is a python library or other smart ways to do it nicely?

Thanks to all!

  • 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-05-14T04:42:05+00:00Added an answer on May 14, 2026 at 4:42 am
    >>> for line in open("file"):
    ...     if "|" in line:
    ...         whatiwant_1=line.split("|")[1]
    ...         if "[" in line:
    ...             whatiwant_2=line.split("[")[1].split("]")[0]
    ...
    >>> print whatiwant_1 , whatiwant_2
    ZP_01631227.1 Nodularia spumigena CCY9414
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SORTED http://drupal.org/node/467190#comment-2068324 Hi friends, I've spent all day to find but can't find :(
I am trying to figure out how to properly implement the friends selector dialogue
I spent some time trying to generate certain tab icons using Android Asset Studio
Sorry if this has been asked before but I've tried searching and can't find
Some friends with the help of various sites check and know when i'm invisible
I am trying to work on some problems and algorithms. I know C++ but
I have some strange restrictions on the following problem. (My friends aren't very good
So i've been spending some time developing an iPhone app - it's a simple
I know this question has been asked and answered many times, and I've spent
I've literally spent the past half hour searching for the solution to this, and

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.