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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:22:53+00:00 2026-06-13T09:22:53+00:00

Possible Duplicate: finding a specific data from a text file in matlab I already

  • 0

Possible Duplicate:
finding a specific data from a text file in matlab

I already opened the text file titled ‘gos.txt’
using the following code:

s={}; 
fid = fopen('gos.txt'); 
tline = fgetl(fid); 
while ischar(tline) 
   s=[s;tline]; 
   tline = fgetl(fid); 
end

I got the result as follows:
s =

'[Term]'    
'id: GO:0008150'
'name: biological_process'
'namespace: biological_process'
'alt_id: GO:0000004'
'alt_id: GO:0007582'
[1x243 char]
[1x445 char]
'subset: goslim_aspergillus'
'subset: goslim_candida'
'subset: goslim_yeast'
'subset: gosubset_prok'
'synonym: "biological process" EXACT []'
'synonym: "biological process unknown" NARROW []'
'synonym: "physiological process" EXACT []'
'xref: Wikipedia:Biological_process'
'[Term]'    
'id: GO:0016740'
'name: transferase activity'
'namespace: molecular_function'
[1x326 char]
'subset: goslim_aspergillus'
'subset: goslim_candida'
'subset: goslim_metagenomics'
'subset: goslim_pir'
'subset: goslim_plant'
'subset: gosubset_prok'
'xref: EC:2'
'xref: Reactome:REACT_25050 "Molybdenum ion transfer onto molybdopterin, Homo sapiens"'
'//is_a: GO:0003674 ! molecular_function'
'is_a: GO:0008150 ! molecular_function (added by Zaid, To be Removed Later)'
'//relationship: part_of GO:0008150 ! biological_process'
'[Term]'    
'id: GO:0016787'
'name: hydrolase activity'
'namespace: molecular_function'
[1x186 char]
'subset: goslim_aspergillus'
'subset: goslim_candida'
'subset: goslim_metagenomics'
'subset: goslim_plant'
'subset: gosubset_prok'
'xref: EC:3'
'//is_a: GO:0003674 ! molecular_function'
'is_a: GO:0016740 ! molecular_function (added by Zaid, to be removed later)'
'relationship: part_of GO:0008150 ! biological_process'
'[Term]'    
'id: GO:0006810'
'name: transport'
'namespace: biological_process'
'alt_id: GO:0015457'
'alt_id: GO:0015460'
[1x255 char]
'subset: goslim_aspergillus'
'subset: goslim_candida'
'synonym: "small molecule transport" NARROW []'
'synonym: "solute:solute exchange" NARROW []'
'synonym: "transport accessory protein activity" RELATED [GOC:mah]'
'is_a: GO:0016787 ! biological_process'
'relationship: part_of GO:0008150 ! biological_process'
.
.
.
.    

the step after is how to take a certain charater and put it in a vector.. for example: I want to put all lines contains ‘id: GO:*******’ and put them in a vector, also I want to get ‘is_a: GO:*******’ to a vector , note that I don’t want to the characters after that in the same line .

  • 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-13T09:22:54+00:00Added an answer on June 13, 2026 at 9:22 am

    You can easily use regexp here – it works for cells:

    matching_lines = s{~cellfun('isempty', regexp(s, '^id: GO'))}
    
    ans =
    
     id: GO:0008150
    
    ans =
    
     id: GO:0016740
    

    extracts all lines that start with id: GO. The cellfun call alone gives you a vector of 0/1, where 1 means that a string in s matches your query.

    Similar line finds ones that contain is_a: GO:. Cutting unnecessary characters from the strings can also be done with regexp.

    Extracting parts of the strings can be done using the 'tokens' parameter of regexp:

    tok = regexp(s, '^id: (GO.*)', 'tokens');
    idx = ~cellfun('isempty', tok);
    v   = cellfun(@(x)x{1}, {tok{idx}});
    sprintf('%s ', v{:})
    
    ans =
    
     GO:0008150 GO:0016740 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Finding the command for a specific PID in Linux from Python I
Possible Duplicate: How do I restore a file from the recycle bin using C#?
Possible Duplicate: Finding date by subtracting X number of days from a particular date
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: Finding 99% coverage in Matlab How can I compute P10, P50 and
Possible Duplicate: Finding local IP addresses using Python's stdlib To get my localhost IP
Possible Duplicate: finding the bounding box of plotted text I've got a simple plot
Possible Duplicate: Finding all Namespaces in an assembly using Reflection (DotNET) let us consider
Possible Duplicate: How do I get a Date from a week number? Finding the
Possible Duplicate: Finding the Variable Name passed to a Function in C# In C#,

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.