<p>Your request is rather specific, so there is no tool...</p>

<p>It is a straightforwards request though. I'd impose the requirement that the structures be solved and no predicted secondary structure. You can do it two ways if using Python. </p>

<h2>PDB</h2>

<p>After downloading all <a href="ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/" rel="nofollow noreferrer">PDB structures</a>, in python with PyMOL (installable with conda, tricky without) you'd do something like</p>

<pre><code>import pymol2, os
from multiprocessing import Pool

def find_motif(file):
    motif = 'AFG'
    try:
        with pymol2.PyMOL() as pymol
            pymol.cmd.load(file)
            seq = pymol.cmd.get_fastastr()
            if motif not in seq:
                return None
            d = {x: []}
            # str.find will cause issues if there is a gap also structure may not start at one.
            pymol.cmd.iterate('resn ALA+PHE+GLY', 'x.append((resi, resn, ss))', space=d)
            sequence = -1
            i = 0
            for residue in d['x']:
                if residue['resn'] = 'ALA':
                    sequence = 0 # lazy enum
                    i = int(residue['resi'])
                elif sequence != -1 :
                    if int(residue['resi']) == i+1 and residue['resn'] = 'PHE':
                        sequence = 1
                    elif int(residue['resi']) == i+2 and residue['resn'] = 'GLY':
                        return (file, i)
                    else:
                        sequence = -1
    finally:
        return (file, None)

if __name__ == '__main__':
    p = Pool(12)
    structure_files = [f for f in os.listdir('pdb') if os.path.splitext(f)[1] == '.pdb']
    verdicts = p.map(finder, structure_files)
    print([(f,v) for f,v in verdicts if v is not None])
</code></pre>

<p>The end result will be a list of PDB with where in the sequence (in that PDB code).
(I wrote this in the reply box, so there may be a typo or two).
PyMOL has a selection algebra called <code>pepseq</code>, which matches missing atoms, but I was a whimp and played it safe by being more verbose. Also, a for loop can be used instead of an iterate. But I think it is slower.</p>

<pre><code>atoms = pymol.cmd.get_model(f"pepseq {target} and name CA")
for atom in atoms.atom:
      if atom.ss == ' ...
</code></pre>

<h2>Uniprot</h2>

<p>In Uniprot, if a protein is crystallised, there will be the feature entries corresponding to the secondary structure. It is sheet or helix. No turns, pi-helices or 3_10 helices. There is no Biopython method for parsing Uniprot XML. I wrote myself a parser and it is not too horrid thing to do —although I <a href="https://blog.matteoferla.com/2019/02/uniprot-xml-and-python-elementtree.html" rel="nofollow noreferrer">monkeypatched elementtree</a>. Alternatively, <code>xmlschema.XMLSchema.to_dict</code> can be used to convert the XML to a dictionary. The advantage of Uniprot is that the residues ids will not require correcting. The disadvantage is parsing XML.</p>

<p>My parser is specific for my application and it is poorly documented (so would not recommend it) but but... I can share <a href="https://github.com/matteoferla/MichelaNGLo-protein-module" rel="nofollow noreferrer">it</a> and <a href="https://github.com/matteoferla/MichelaNGLo-human-protein-data" rel="nofollow noreferrer">human data</a>. I'd be used like:</p>

<pre><code> import os
 from michelanglo_protein import ProteinCore
 ProteinCore.settings.startup(data_folder='protein-data')
 p = ProteinCore().gload(file=os.path.join('gpickle','Q86V25.gpz'))
 #print(p.asdict())
 if 'helix' in p.features:
        n = p.sequence.find( ...
        for ... p.features['helix'] #('helix', 'turn', 'strand')
        if x &lt; n &lt; y ...
</code></pre>

CC BY-SA 4.0
2020-01-28T16:42:02.233Z
Thank you. Parsing it on one's own doesn't look complicated. Still, I somehow balk at the idea that my needs are so specific... You are positive there's no such tool?
user75619
CC BY-SA 4.0
2020-01-28T17:12:12.937Z
Proving a negative is hard, so I can only say I have never read of one.But I had a similar problem some time back and did it manually. Furthermore, logistically a server to do this would need its data pre-generated but then the combinatorial issues will be huge so would not work...
Matteo Ferla
CC BY-SA 4.0
2020-01-28T23:01:55.683Z
there is msdmotif https://www.ebi.ac.uk/pdbe/docs/Tutorials/msdmotif/introduction.html but I suspect the query might be a bit slow as there would be a lot of hits
gilleain
CC BY-SA 4.0
2020-01-29T09:19:01.253Z
I just realised that in my comment I said something incredibly daft. A server is totally possible, they just need to store sequence+SS type sequence as opposed to all combinations. Apologies.
Matteo Ferla
CC BY-SA 4.0
2020-01-18T10:11:58.690Z
2020-01-28T17:04:46.340Z
2020-01-28T17:04:46.340Z
Matteo Ferla
<p>I need to find peptides/proteins with a certain sequence of amino acids in a certain type of secondary structure. For example, "ALA PHE GLY" in alpha-helix. Is there any tool that does that?</p>

<protein-structure><secondary-structure>
Searching for proteins by primary and secondary structure
# Searching for proteins by primary and secondary structure

(Asked by: username_0 on 2020-01-17)

I need to find peptides/proteins with a certain sequence of amino acids in a certain type of secondary structure. For example, "ALA PHE GLY" in alpha-helix. Is there any tool that does that?

**Tags:** protein-structure, secondary-structure

---

## 1 answers

### Answer by username_1 on 2020-01-18. Score: 3 | Accepted answer

Your request is rather specific, so there is no tool...
It is a straightforwards request though. I'd impose the requirement that the structures be solved and no predicted secondary structure. You can do it two ways if using Python. 
PDB
After downloading all PDB structures, in python with PyMOL (installable with conda, tricky without) you'd do something like
import pymol2, os
from multiprocessing import Pool

def find_motif(file):
    motif = 'AFG'
    try:
        with pymol2.PyMOL() as pymol
            pymol.cmd.load(file)
            seq = pymol.cmd.get_fastastr()
            if motif not in seq:
                return None
            d = {x: []}
            # str.find will cause issues if there is a gap also structure may not start at one.
            pymol.cmd.iterate('resn ALA+PHE+GLY', 'x.append((resi, resn, ss))', space=d)
            sequence = -1
            i = 0
            for residue in d['x']:
                if residue['resn'] = 'ALA':
                    sequence = 0 # lazy enum
                    i = int(residue['resi'])
                elif sequence != -1 :
                    if int(residue['resi']) == i+1 and residue['resn'] = 'PHE':
                        sequence = 1
                    elif int(residue['resi']) == i+2 and residue['resn'] = 'GLY':
                        return (file, i)
                    else:
                        sequence = -1
    finally:
        return (file, None)

if __name__ == '__main__':
    p = Pool(12)
    structure_files = [f for f in os.listdir('pdb') if os.path.splitext(f)[1] == '.pdb']
    verdicts = p.map(finder, structure_files)
    print([(f,v) for f,v in verdicts if v is not None])

The end result will be a list of PDB with where in the sequence (in that PDB code).
(I wrote this in the reply box, so there may be a typo or two).
PyMOL has a selection algebra called pepseq, which matches missing atoms, but I was a whimp and played it safe by being more verbose. Also, a for loop can be used instead of an iterate. But I think it is slower.
atoms = pymol.cmd.get_model(f"pepseq {target} and name CA")
for atom in atoms.atom:
      if atom.ss == ' ...

Uniprot
In Uniprot, if a protein is crystallised, there will be the feature entries corresponding to the secondary structure. It is sheet or helix. No turns, pi-helices or 3_10 helices. There is no Biopython method for parsing Uniprot XML. I wrote myself a parser and it is not too horrid thing to do —although I monkeypatched elementtree. Alternatively, xmlschema.XMLSchema.to_dict can be used to convert the XML to a dictionary. The advantage of Uniprot is that the residues ids will not require correcting. The disadvantage is parsing XML.
My parser is specific for my application and it is poorly documented (so would not recommend it) but but... I can share it and human data. I'd be used like:
 import os
 from michelanglo_protein import ProteinCore
 ProteinCore.settings.startup(data_folder='protein-data')
 p = ProteinCore().gload(file=os.path.join('gpickle','Q86V25.gpz'))
 #print(p.asdict())
 if 'helix' in p.features:
        n = p.sequence.find( ...
        for ... p.features['helix'] #('helix', 'turn', 'strand')
        if x < n < y ...

> **Comments:**
> **username_0**: Thank you. Parsing it on one's own doesn't look complicated. Still, I somehow balk at the idea that my needs are so specific... You are positive there's no such tool?  
> **username_1**: Proving a negative is hard, so I can only say I have never read of one.But I had a similar problem some time back and did it manually. Furthermore, logistically a server to do this would need its data pre-generated but then the combinatorial issues will be huge so would not work...  
> **username_2**: there is msdmotif https://www.ebi.ac.uk/pdbe/docs/Tutorials/msdmotif/introduction.html but I suspect the query might be a bit slow as there would be a lot of hits  
> **username_1**: I just realised that in my comment I said something incredibly daft. A server is totally possible, they just need to store sequence+SS type sequence as opposed to all combinations. Apologies.  

---

