<p>If your file is in PDB format as the one shown <a href="https://files.rcsb.org/view/6C4A.pdb" rel="nofollow noreferrer">here</a> in .pdb format then you can simply extract your desired fields using <a href="https://www.gnu.org/software/sed/manual/sed.html" rel="nofollow noreferrer">sed</a> which is a programming language used to parse and transform text. As for this<a href="https://files.rcsb.org/view/6C4A.pdb" rel="nofollow noreferrer"> structure </a>i.e 6C4A in .pdb format HETNAM and HETSYN can be extracted using sed as follows:</p>

<pre><code>sed  -n -e '/HETNAM/ p' -e '/HETSYN/ p'  6C4A.pdb

HETNAM     EJA S-[(1Z)-2-CARBOXY-N-HYDROXYETHANIMIDOYL]-L-CYSTEINE              
HETNAM     PYR PYRUVIC ACID                                                     
HETNAM      MG MAGNESIUM ION                                                    
HETNAM     3NP 3-NITROPROPANOIC ACID                                            
HETNAM     PEG DI(HYDROXYETHYL)ETHER                                            
HETNAM     EPE 4-(2-HYDROXYETHYL)-1-PIPERAZINE ETHANESULFONIC ACID              
HETSYN     EPE HEPES
</code></pre>

CC BY-SA 4.0
2018-06-08T14:09:31.140Z
Thanks, seems pretty straightforward. How do I use sed? Is it a way to apply it on R ?
Adrian Smith
CC BY-SA 4.0
2018-06-08T15:03:11.583Z
It is straight forward. Write this command on Linux command line/terminal with your input file present in current working directory.
Ammar Sabir Cheema
CC BY-SA 4.0
2018-06-08T15:09:33.483Z
Secondly for using sed in R you should check [this](https://jpwendler.wordpress.com/2013/07/31/using-a-linux-sed-command-to-retrieve-specific-rows-from-a-file-from-r/amp/)
Ammar Sabir Cheema
CC BY-SA 4.0
2018-06-08T13:56:34.897Z
2018-06-08T13:56:34.897Z
Ammar Sabir Cheema
<p>I'm using R and I'm trying to import specific records from a PDB file (e.g. <code>HETNAM</code>, <code>HETSYN</code>). Unfortunately, it seems the <code>read.pdb</code> function of either <code>biomaRt</code> or <code>Rpdb</code> aren't capable of it.</p>

<p>Any ideas?</p>

<p>Thanks</p>

CC BY-SA 4.0
2018-06-08T12:07:11.330Z
Hi, could you show what have you tried? As far as I know it is not so difficult to parse the files, but that depends on the format of the file you downloaded.
llrs
CC BY-SA 4.0
2018-06-08T14:10:08.070Z
Hi, nothing special, I just used the read.pdb function to read in the PDB files.
Adrian Smith
<r><pdb>
Using R to import specific records from a PDB file
# Using R to import specific records from a PDB file

(Asked by: username_0 on 2018-06-08)

I'm using R and I'm trying to import specific records from a PDB file (e.g. `HETNAM`, `HETSYN`). Unfortunately, it seems the `read.pdb` function of either `biomaRt` or `Rpdb` aren't capable of it.

Any ideas?

Thanks

**Tags:** r, pdb
> **Comments:**
> **username_1**: Hi, could you show what have you tried? As far as I know it is not so difficult to parse the files, but that depends on the format of the file you downloaded.  
> **username_0**: Hi, nothing special, I just used the read.pdb function to read in the PDB files.  

---

## 1 answers

### Answer by username_2 on 2018-06-08. Score: 4 | Accepted answer

If your file is in PDB format as the one shown here in .pdb format then you can simply extract your desired fields using sed which is a programming language used to parse and transform text. As for this structure i.e 6C4A in .pdb format HETNAM and HETSYN can be extracted using sed as follows:
sed  -n -e '/HETNAM/ p' -e '/HETSYN/ p'  6C4A.pdb

HETNAM     EJA S-[(1Z)-2-CARBOXY-N-HYDROXYETHANIMIDOYL]-L-CYSTEINE              
HETNAM     PYR PYRUVIC ACID                                                     
HETNAM      MG MAGNESIUM ION                                                    
HETNAM     3NP 3-NITROPROPANOIC ACID                                            
HETNAM     PEG DI(HYDROXYETHYL)ETHER                                            
HETNAM     EPE 4-(2-HYDROXYETHYL)-1-PIPERAZINE ETHANESULFONIC ACID              
HETSYN     EPE HEPES

> **Comments:**
> **username_0**: Thanks, seems pretty straightforward. How do I use sed? Is it a way to apply it on R ?  
> **username_2**: It is straight forward. Write this command on Linux command line/terminal with your input file present in current working directory.  
> **username_2**: Secondly for using sed in R you should check [this](https://jpwendler.wordpress.com/2013/07/31/using-a-linux-sed-command-to-retrieve-specific-rows-from-a-file-from-r/amp/)  

---

