By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

parse for info.

P: 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
Share this Question
Share on Google+
3 Replies


dlite922
Expert 100+
P: 1,584
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

P: 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
Expert 2.5K+
P: 4,258
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

Post your reply

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