vidyashankara Posted May 16, 2006 Share Posted May 16, 2006 I have a text file named 123.pdb. It contains[code]HEADER LIPID TRANSPORT 23-SEP-97 1AV1 TITLE CRYSTAL STRUCTURE OF HUMAN APOLIPOPROTEIN A-I COMPND MOL_ID: 1; COMPND 2 MOLECULE: APOLIPOPROTEIN A-I; COMPND 3 CHAIN: A, B, C, D; COMPND 4 FRAGMENT: LIPID-BINDING DOMAIN; COMPND 5 SYNONYM: APO A-I; COMPND 6 ENGINEERED: YES; COMPND 7 MUTATION: N-TERMINAL MET, DEL(1-43) SOURCE MOL_ID: 1; SOURCE 2 ORGANISM_SCIENTIFIC: HOMO SAPIENS; SOURCE 3 ORGANISM_COMMON: HUMAN; SOURCE 4 TISSUE: BLOOD; SOURCE 5 EXPRESSION_SYSTEM: ESCHERICHIA COLI; SOURCE 6 EXPRESSION_SYSTEM_STRAIN: BL21 (DE3); SOURCE 7 EXPRESSION_SYSTEM_VECTOR_TYPE: PLASMID; SOURCE 8 EXPRESSION_SYSTEM_VECTOR: PGEMEX KEYWDS LIPOPROTEIN, LIPID TRANSPORT, CHOLESTEROL METABOLISM, KEYWDS 2 ATHEROSCLEROSIS, HDL, LCAT-ACTIVATION EXPDTA X-RAY DIFFRACTION [/code]I am writing a code to read this file and echo the output. Like.[code]Description:Name: CRYSTAL STRUCTURE OF HUMAN APOLIPOPROTEIN A-IPDB ID : 1av1Number of Chains: A, B, C, D;Experimental Method: X-RAY DIFFRACTION [/code]I have the following code.[code]$id = $_GET["file"];$file = "$id.pdb";$contents = file_get_contents($file);$title= preg_replace('/^(?!TITLE).*?(?:\n|$)/m','',$contents);$exp= preg_replace('/^(?!EXPDTA).*?(?:\n|$)/m','',$contents);$chain= preg_replace('/^(?!COMPND 3 CHAIN:).*?(?:\n|$)/m','',$contents);echo "Description:<p>";echo "Name: $title<br>";echo "PDB ID : $id<br>";echo "Number of Chains: $chain<br>";echo "Experimental Method:$exp<br>";[/code]This outputs [code]Description:Name: TITLE CRYSTAL STRUCTURE OF HUMAN APOLIPOPROTEIN A-IPDB ID : 1av1Number of Chains: COMPND 3 CHAIN: A, B, C, D;Experimental Method:EXPDTA X-RAY DIFFRACTION [/code]Basically the script reads the line starting with TITLE, COMPND 3 CHAIN and EXPDTA to get this information. what do i modify in the script to omit these words? the script should just show Name: CRYSTAL STRUCTURE OF HUMAN APOLIPOPROTEIN A-Iinstead of Name: TITLE CRYSTAL STRUCTURE OF HUMAN APOLIPOPROTEIN A-IThe starting word TITLE should be omitted.If i sayREAD from 123.pdb. The lines starting from TITLE, It must output what comes after TITLE, not the whole line. Any help would be appreciated!ThanksVidyashankara Link to comment https://forums.phpfreaks.com/topic/9810-reading-specific-parts-of-a-text-file-in-php/ Share on other sites More sharing options...
vidyashankara Posted May 16, 2006 Author Share Posted May 16, 2006 I got it, just replaced the text with a space :) Link to comment https://forums.phpfreaks.com/topic/9810-reading-specific-parts-of-a-text-file-in-php/#findComment-36400 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.