parse for info.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idorjee
    New Member
    • Mar 2007
    • 76

    parse for info.

    hi,
    i'm trying to parse the info. retrieved from a web page as follows:
    Code:
    $text_info = curl_init("http://domain.com/info.txt");
    $buffer = curl_exec($text_info);
    if (preg_match_all("/DE\s+(.+)/", $buffer, $desc)) { $description .= $desc[1]; }
    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.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    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.

    Comment

    • idorjee
      New Member
      • Mar 2007
      • 76

      #3
      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!

      Code:
      ID   S35A2_MOUSE             Reviewed;         390 AA.
      AC   Q9R0M8;
      DT   01-DEC-2000, integrated into UniProtKB/Swiss-Prot.
      DT   01-MAY-2000, sequence version 1.
      DT   15-JAN-2008, entry version 53.
      [U]DE   UDP-galactose translocator (UDP-galactose transporter) (UGT) (UDP-Gal-
      DE   Tr) (Solute carrier family 35 member A2) (mUGT1).[/U]
      GN   Name=Slc35a2; Synonyms=Ugt1;
      OS   Mus musculus (Mouse).
      OC   Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; 
      OC   Mammalia; Eutheria; Euarchontoglires; Glires; Rodentia; Sciurognathi; 
      OC   Muroidea; Muridae; Murinae; Mus. 
      OX   NCBI_TaxID=10090;
      RN   [1]
      RP   NUCLEOTIDE SEQUENCE [MRNA].
      RC   STRAIN=BALB/c;
      RX   MEDLINE=20047065; PubMed=10578063 [NCBI, ExPASy, EBI, Israel, Japan];
      RA   Ishida N., Yoshioka S., Iida M., Sudo K., Miura N., Aoki K.,
      RA   Kawakita M.;
      RT   "Indispensability of transmembrane domains of Golgi UDP-galactose
      RT   transporter as revealed by analysis of genetic defects in UDP-
      RT   galactose transporter-deficient murine had-1 mutant cell lines and
      RT   construction of deletion mutants.";
      RL   J. Biochem. 126:1107-1117(1999).
      RN   [2]
      RP   NUCLEOTIDE SEQUENCE [LARGE SCALE MRNA].
      RC   STRAIN=FVB/N; TISSUE=Salivary gland;
      RX   PubMed=15489334 [NCBI, ExPASy, EBI, Israel, Japan]; DOI=10.1101/gr.2596504;
      RG   The MGC Project Team;
      RT   "The status, quality, and expansion of the NIH full-length cDNA
      RT   project: the Mammalian Gene Collection (MGC).";
      RL   Genome Res. 14:2121-2127(2004).
      CC   -!- FUNCTION: Transports nucleotide sugars from the cytosol into Golgi
      CC       vesicles where glycosyltransferases function.
      CC   -!- SUBCELLULAR LOCATION: Golgi apparatus membrane; Multi-pass
      CC       membrane protein.
      CC   -!- SIMILARITY: Belongs to the nucleotide-sugar transporter family.
      CC       SLC35A subfamily.
      CC   -----------------------------------------------------------------------
      CC   Copyrighted by the UniProt Consortium, see http://www.uniprot.org/terms
      CC   Distributed under the Creative Commons Attribution-NoDerivs License
      CC   -----------------------------------------------------------------------
      DR   EMBL; AB027147; BAA86885.1; -; mRNA. [EMBL / GenBank / DDBJ] [CoDingSequence]
      DR   EMBL; BC037701; AAH37701.1; -; mRNA. [EMBL / GenBank / DDBJ] [CoDingSequence]
      DR   PIR; JC7162; JC7162.
      DR   RefSeq; NP_001077406.1; -.
      DR   UniGene; Mm.214976; -.
      DR   Ensembl; ENSMUSG00000031156; Mus_musculus
      DR   GeneID; 22232; -.
      DR   MGI; MGI:1345297; Slc35a2.
      DR   ArrayExpress; Q9R0M8; -.
      DR   GermOnline; ENSMUSG00000031156; Mus_musculus
      DR   GO; GO:0000139; C:Golgi membrane; IDA:MGI.
      DR   GO; GO:0005459; F:UDP-galactose transmembrane transporter act...; IDA:MGI.
      DR   GO; GO:0008643; P:carbohydrate transport; IDA:MGI.
      DR   InterPro; IPR007271; Nuc_sug_transpt.
      DR   InterPro; IPR004689; UDPgal_transpt.
      DR   InterPro; Graphical view of domain structure.
      DR   PANTHER; PTHR10231; Nuc_sug_transpt; 1.
      DR   Pfam; PF04142; Nuc_sug_transp; 1.
      DR   Pfam; Graphical view of domain structure.
      DR   TIGRFAMs; TIGR00803; nst; 1.
      DR   CMR; Q9R0M8.
      DR   ProDom [Domain structure / List of seq. sharing at least 1 domain]
      DR   BLOCKS; Q9R0M8.
      DR   ProtoNet; Q9R0M8.
      DR   DIP; Q9R0M8.
      DR   ModBase; Q9R0M8.
      DR   SWISS-2DPAGE; GET REGION ON 2D PAGE.
      PE   2: Evidence at transcript level;
      KW   Golgi apparatus; Membrane; Sugar transport; Transmembrane; Transport.
      FT   CHAIN         1    390       UDP-galactose translocator.
      FT                                /FTId=PRO_0000213354.
      FT   TRANSMEM      3     23       Potential.
      FT   TRANSMEM     37     57       Potential.
      FT   TRANSMEM     65     85       Potential.
      FT   TRANSMEM     97    117       Potential.
      FT   TRANSMEM    140    160       Potential.
      FT   TRANSMEM    169    189       Potential.
      FT   TRANSMEM    200    220       Potential.
      FT   TRANSMEM    238    258       Potential.
      FT   TRANSMEM    269    289       Potential.
      FT   TRANSMEM    315    335       Potential.
      SQ   SEQUENCE   390 AA;  40766 MW;  F7CD57C5C0D401B8 CRC64;
           MAAVGVGGST AAAGAGAVSS GALEPGSTTA AHRRLKYISL AVLVVQNASL ILSIRYARTL
           PGDRFFATTA VVMAEVLKGL TCLLLLFAQK RGNVKHLVLF LHEAVLVQYV DTLKLAVPSL
           IYTLQNNLQY VAISNLPAAT FQVTYQLKIL TTALFSVLML NRSLSRLQWA SLLLLFTGVA
           IVQAQQAGGS GPRPLDQNPG AGLAAVVASC LSSGFAGVYF EKILKGSSGS VWLRNLQLGL
           FGTALGLVGL WWAEGTAVAS QGFFFGYTPA VWGVVLNQAF GGLLVAVVVK YADNILKGFA
           TSLSIVLSTV ASIRLFGFHL DPLFALGAGL VIGAVYLYSL PRGAVKAIAS ASASGPCIHQ
           QPPGQPPPPQ LSSRGDLTTE PFLPKSVLVK
      //

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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

        Comment

        Working...