473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

parse for info.

76
hi,
i'm trying to parse the info. retrieved from a web page as follows:
Expand|Select|Wrap|Line Numbers
  1. $text_info = curl_init("http://domain.com/info.txt");
  2. $buffer = curl_exec($text_info);
  3. if (preg_match_all("/DE\s+(.+)/", $buffer, $desc)) { $description .= $desc[1]; } 
  4.  
but the problem is, there are several lines in the $buffer variable that has the same pattern. for example,

DE Potassium voltage-gated channel subfamily A member 3 (Voltage-gated
DE potassium channel subunit Kv1.3) (HPCN3) (HGK5) (HuKIII) (HLK3).

which is what i am interested in, but also, there are lines that the above pattern matches, such as,

RP NUCLEOTIDE SEQUENCE [GENOMIC DNA].

which i am not interested in. i tried using '^' infront of DE ("/^DE\s+(.+)/"), but doesn't work at all.
please help.
Thanks a lot in advance.
Feb 23 '08 #1
3 1380
dlite922
1,584 Expert 1GB
can you give us a sample file (or chunk of file) that is typical, and highlight the lines or strings your interested in.

Without seeing the whole thing, we can't give you the best possible regex.
Feb 24 '08 #2
idorjee
76
thanks for your reply. here's the file that i've been trying to parse. the underlined part (line 6 & 7) is what i am interested in. i would like the retrieved line look like:
UDP-galactose translocator (UDP-galactose transporter) (UGT) (UDP-Gal-Tr) (Solute carrier family 35 member A2) (mUGT1).

Thank you!

Expand|Select|Wrap|Line Numbers
  1. ID   S35A2_MOUSE             Reviewed;         390 AA.
  2. AC   Q9R0M8;
  3. DT   01-DEC-2000, integrated into UniProtKB/Swiss-Prot.
  4. DT   01-MAY-2000, sequence version 1.
  5. DT   15-JAN-2008, entry version 53.
  6. DE   UDP-galactose translocator (UDP-galactose transporter) (UGT) (UDP-Gal-
  7. DE   Tr) (Solute carrier family 35 member A2) (mUGT1).
  8. GN   Name=Slc35a2; Synonyms=Ugt1;
  9. OS   Mus musculus (Mouse).
  10. OC   Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; 
  11. OC   Mammalia; Eutheria; Euarchontoglires; Glires; Rodentia; Sciurognathi; 
  12. OC   Muroidea; Muridae; Murinae; Mus. 
  13. OX   NCBI_TaxID=10090;
  14. RN   [1]
  15. RP   NUCLEOTIDE SEQUENCE [MRNA].
  16. RC   STRAIN=BALB/c;
  17. RX   MEDLINE=20047065; PubMed=10578063 [NCBI, ExPASy, EBI, Israel, Japan];
  18. RA   Ishida N., Yoshioka S., Iida M., Sudo K., Miura N., Aoki K.,
  19. RA   Kawakita M.;
  20. RT   "Indispensability of transmembrane domains of Golgi UDP-galactose
  21. RT   transporter as revealed by analysis of genetic defects in UDP-
  22. RT   galactose transporter-deficient murine had-1 mutant cell lines and
  23. RT   construction of deletion mutants.";
  24. RL   J. Biochem. 126:1107-1117(1999).
  25. RN   [2]
  26. RP   NUCLEOTIDE SEQUENCE [LARGE SCALE MRNA].
  27. RC   STRAIN=FVB/N; TISSUE=Salivary gland;
  28. RX   PubMed=15489334 [NCBI, ExPASy, EBI, Israel, Japan]; DOI=10.1101/gr.2596504;
  29. RG   The MGC Project Team;
  30. RT   "The status, quality, and expansion of the NIH full-length cDNA
  31. RT   project: the Mammalian Gene Collection (MGC).";
  32. RL   Genome Res. 14:2121-2127(2004).
  33. CC   -!- FUNCTION: Transports nucleotide sugars from the cytosol into Golgi
  34. CC       vesicles where glycosyltransferases function.
  35. CC   -!- SUBCELLULAR LOCATION: Golgi apparatus membrane; Multi-pass
  36. CC       membrane protein.
  37. CC   -!- SIMILARITY: Belongs to the nucleotide-sugar transporter family.
  38. CC       SLC35A subfamily.
  39. CC   -----------------------------------------------------------------------
  40. CC   Copyrighted by the UniProt Consortium, see http://www.uniprot.org/terms
  41. CC   Distributed under the Creative Commons Attribution-NoDerivs License
  42. CC   -----------------------------------------------------------------------
  43. DR   EMBL; AB027147; BAA86885.1; -; mRNA. [EMBL / GenBank / DDBJ] [CoDingSequence]
  44. DR   EMBL; BC037701; AAH37701.1; -; mRNA. [EMBL / GenBank / DDBJ] [CoDingSequence]
  45. DR   PIR; JC7162; JC7162.
  46. DR   RefSeq; NP_001077406.1; -.
  47. DR   UniGene; Mm.214976; -.
  48. DR   Ensembl; ENSMUSG00000031156; Mus_musculus
  49. DR   GeneID; 22232; -.
  50. DR   MGI; MGI:1345297; Slc35a2.
  51. DR   ArrayExpress; Q9R0M8; -.
  52. DR   GermOnline; ENSMUSG00000031156; Mus_musculus
  53. DR   GO; GO:0000139; C:Golgi membrane; IDA:MGI.
  54. DR   GO; GO:0005459; F:UDP-galactose transmembrane transporter act...; IDA:MGI.
  55. DR   GO; GO:0008643; P:carbohydrate transport; IDA:MGI.
  56. DR   InterPro; IPR007271; Nuc_sug_transpt.
  57. DR   InterPro; IPR004689; UDPgal_transpt.
  58. DR   InterPro; Graphical view of domain structure.
  59. DR   PANTHER; PTHR10231; Nuc_sug_transpt; 1.
  60. DR   Pfam; PF04142; Nuc_sug_transp; 1.
  61. DR   Pfam; Graphical view of domain structure.
  62. DR   TIGRFAMs; TIGR00803; nst; 1.
  63. DR   CMR; Q9R0M8.
  64. DR   ProDom [Domain structure / List of seq. sharing at least 1 domain]
  65. DR   BLOCKS; Q9R0M8.
  66. DR   ProtoNet; Q9R0M8.
  67. DR   DIP; Q9R0M8.
  68. DR   ModBase; Q9R0M8.
  69. DR   SWISS-2DPAGE; GET REGION ON 2D PAGE.
  70. PE   2: Evidence at transcript level;
  71. KW   Golgi apparatus; Membrane; Sugar transport; Transmembrane; Transport.
  72. FT   CHAIN         1    390       UDP-galactose translocator.
  73. FT                                /FTId=PRO_0000213354.
  74. FT   TRANSMEM      3     23       Potential.
  75. FT   TRANSMEM     37     57       Potential.
  76. FT   TRANSMEM     65     85       Potential.
  77. FT   TRANSMEM     97    117       Potential.
  78. FT   TRANSMEM    140    160       Potential.
  79. FT   TRANSMEM    169    189       Potential.
  80. FT   TRANSMEM    200    220       Potential.
  81. FT   TRANSMEM    238    258       Potential.
  82. FT   TRANSMEM    269    289       Potential.
  83. FT   TRANSMEM    315    335       Potential.
  84. SQ   SEQUENCE   390 AA;  40766 MW;  F7CD57C5C0D401B8 CRC64;
  85.      MAAVGVGGST AAAGAGAVSS GALEPGSTTA AHRRLKYISL AVLVVQNASL ILSIRYARTL
  86.      PGDRFFATTA VVMAEVLKGL TCLLLLFAQK RGNVKHLVLF LHEAVLVQYV DTLKLAVPSL
  87.      IYTLQNNLQY VAISNLPAAT FQVTYQLKIL TTALFSVLML NRSLSRLQWA SLLLLFTGVA
  88.      IVQAQQAGGS GPRPLDQNPG AGLAAVVASC LSSGFAGVYF EKILKGSSGS VWLRNLQLGL
  89.      FGTALGLVGL WWAEGTAVAS QGFFFGYTPA VWGVVLNQAF GGLLVAVVVK YADNILKGFA
  90.      TSLSIVLSTV ASIRLFGFHL DPLFALGAGL VIGAVYLYSL PRGAVKAIAS ASASGPCIHQ
  91.      QPPGQPPPPQ LSSRGDLTTE PFLPKSVLVK
  92. //
  93.  
Feb 24 '08 #3
ronverdonk
4,258 Expert 4TB
Reading another thread, Displaying part of a remote file, in this forum, I saw that cURL returned text buffer does NOT have line breaks.
So it will be hard for you to filter out your string at the beginning of a line. You could read the file in an array and then filter the DE-starting lines out.

See THIS POST in the referred thread that shows how you could do it.

Ronald
Feb 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
5
by: Markus Kling | last post by:
"double.Parse(double.MaxValue.ToString())" yields the following Exception: Value was either too large or too small for a Double. at System.Number.ParseDouble(String value, NumberStyles options,...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
by: basswhizz | last post by:
Hi guys im having trouble with somethings else now can you help out thanks!! Im getting this error message Parse error: syntax error, unexpected $end Here's my code cheers!!] <?php //...
4
by: mmiller | last post by:
I have a pretty limited knowledge of PHP. My scenario is: I want one form to have two (2) submit buttons. I want one button to submit an email to a specific address then redirect to a page, and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.