Structural Bioinformatics Library
Template C++ / Python API for developping structural bioinformatics applications.
User Manual


Authors: R. Tetley and F. Cazals


When processing large amounts of protein sequences, having indicators on certain sites of interest, such as transmembrane parts or binding sites can be interesting. As an example, one could want to find proteins wich contain a transmembrane region that is at least 30 amino-acids long. Such is the purpose of sequence annotations, allowing users to search for certain characteristics in annotated sequence. We provide a set of two Python modules: one which defines annotated sequences and provides some standard annotators and one to filter a set of protein sequences using properties on these annotations.


An annotation on a protein sequence is a triplet composed of a feature key, a residue sequence number range (or list) and a description. $\text{\uniprot}$ provides a list of standard features:

  • The feature key defines the type of feature
  • The range locates the feature on the sequence
  • The description (optional) gives additional information on the feature

As an example, the EFF1 protein ( contains:

  • A Transmembrane region (feature key)
  • Between residues 556 and 576 (residue range)
  • Which is Helical (optional description)

Python modules

Sequence annotations

The Python module SBL/ provides the SBL::Sequence_annotators::Annotated_sequence class. Such an object should be initialized with a name as well as a fasta sequence. An annotator should then be used to add sequence annotations.

Annotations using Phoebius

phoebius is a combined transmembrane topology and signal peptide prediction method [102] , based upon profile Hidden Markov models.

The Python module SBL/ , provides the class SBL::Sequence_annotators::Phobius_annotator which uses the $\text{phoebius}$ executable to annotate a sequence.

An annotator has a single function, annotate, which takes an annotated sequence object in argument, and produces annotations by exploiting its fasta sequence

For example, the phobius annotator, when given an annotated sequence object, will write its fasta sequence to a file, run the $\text{phoebius}$ exectuable, and parse the results. These results will be used to annotate the sequence.

import re #regular expressions
import string
import sys #misc system
import os
#This class runs the Phobius executable to annotate a sequence
__standard_feature_keys__ = {"DOMAIN" : "Domain", "TOPO_DOM" : "TDomain", "SIGNAL" : "Signal", "REGION" : "Region", "TRANSMEM" : "Transmembrane"}
__standard_descriptions__ = {"CYTOPLASMIC" : "Cyto", "NON CYTOPLASMIC" : "Non-cyto", "N-REGION" : "N", "H-REGION" : "H", "C-REGION" : "C", "" : ""}
def annotate(self, annotated_sequence):
phobius_cmd = " tmp.fasta &> tmp.phobius"
rm_cmd = "rm tmp.fasta tmp.phobius"
tmp_fasta = open("tmp.fasta", "w")
tmp_fasta.write(">%s\n%s\n" % (, annotated_sequence.fasta_seq))
phobius_file = open("tmp.phobius")
for line in phobius_file:
result =
if result:
feature_key =
range_begin = int(
range_end = int(
feature_description = ""
if != None:
feature_description =
feature = sf.Feature(self.__standard_feature_keys__[feature_key], (range_begin, range_end), self.__standard_descriptions__[feature_description])
Users can design their own annotator by creating a functor object which has a member function annotate which fills the features field of the annotated sequence.

Sequence filters

Through the SBL/ module, we provide a set of filters which allow to filter a set of annotated sequences by using criterions on their annotations.

A sequence filter object is a functor containing the filter member function, which takes an annotated sequence as argument and returns true if the given sequence follows the defined restrictions.

For example, the SBL::Sequence_filters::Transmembrane_filter class will simply look for a "Transmembrane" feature in the annotated sequence.

import re #regular expressions
import string
import sys #misc system
import os
import Sequence_annotators
def filter(self, annotated_sequence):
return self.is_transmembrane(annotated_sequence)
def is_transmembrane(self, annotated_sequence):
if annotated_sequence.get_features("Transmembrane"):
return True
return False
Users can define their own filters.


In this example, we parse a fasta file and annotate each listed fasta sequence using the $\text{\phoebius}$ annotator.

We then use the SBL::Sequence_filters::Class_II_filter class to assess wether the given sequence is a viable class II fusion protein candidate.

#! /usr/bin/python3
import re #regular expressions
import string
import sys #misc system
import os
from optparse import OptionParser
from SBL.Sequence_filters import *
name_line_re = re.compile(">([A-Za-z0-9\.]+)")
fasta_line_re = re.compile("^[A-Za-z]+")
parser = OptionParser()
# parse the results for a unique file
parser.add_option("-f", "--fasta", dest="fasta", type="string", help="Input the fasta file")
(options, args) = parser.parse_args()
if not options.fasta:
sys.exit("You must provide a valid fasta file")
#read the fasta file
fasta_sequences = []
fasta_file = open(options.fasta)
name = "No name"
for line in fasta_file:
name_line =
fasta_line =
if name_line:
name =
if fasta_line:
fasta_sequences.append((name, line))
name = "No name"
#create annotator and filter
phobius = Phobius_annotator()
class_II = Class_II_filter()
ann_seq_list = []
#analyse each sequence contained in the file
for name, fasta in fasta_sequences:
ann_seq = Annotated_sequence(name, fasta)
if class_II.filter(ann_seq):
print("Probable class II candidate: %s" % (