We address the problem of improving residue-wise score-based predictors for protein interface residues as a node labeling problem for undirected graphs using the model class of conditional random fields (CRFs). Lafferty *et al.*[30] were the first who applied CRFs to the problem of labeling sequence data. Li *et al.*[28] used line CRFs to address the interaction site prediction. They have the advantage that the Viterbi algorithm well-known from decoding HMMs can be used to efficiently infer the most likely labeling sequence. Very useful and illustrative presentations on CRFs are given in [31, 32, 36, 37]. Above CRF-based models make the assumption that the label of one residue is conditionally independent of the labels of all other residues given the labels of the two adjacent residues in the protein sequence. To the best of our knowledge, we are the first to employ a graphical model that takes the spatial neighborhood of residues located on the protein surface into account.

This section is subdivided into three parts. We first explain how we model protein surfaces by pairwise CRFs. Then we introduce our new inference method. Finally, we elucidate our training method.

### Using conditional random fields to model protein surfaces

For every protein under study that has *n* surface residues, a pair of random vectors (**X**, **Y**) is considered. The vector **X** is the *observation* that represents the knowledge about this protein that is utilized in the prediction, e.g. the 3D structure of the target protein and a multiple sequence alignment together with homologs.

The vector **Y** is a random sequence of length *n* over the alphabet {I,N} that labels the index set {1,2,…,*n*}, which in turn is called the set of *positions* (of the surface residues). The label I represents interface residues, whereas the label N represents non-interface residues. {I,N}^{n} is the set of all label sequences of length *n* over {I,N}. We will also call them *assignments* as the term ‘label sequence’ may lead to confusion when applied below to subsets of {1,2,…,*n*} that are not contiguous sequences.

Let \mathcal{G}=(\mathcal{V},\mathcal{E}) be the *neighborhood graph*, where \mathcal{V}=\{1,2,\dots ,n\} is the set of positions, is the set of edges that typically results from an atom-distance-based neighborhood definition for positions. We assume for convenience in notation that has no isolated nodes. Cases with isolated nodes could trivially be reduced to cases without isolated nodes. Let be the set of ’s *cliques*, which we refer to as *node cliques*. For a node clique c\in \mathcal{C} and an assignment **y** we denote by **y**_{
c
} the restriction of **y** to the positions belonging to the node clique *c*. For *c*={*i*} and *c*={*i*,*j*} we write *y*_{
i
} and \left({y}_{i},{y}_{j}\right) rather than **y**_{{i}} and **y**_{{i,j}}.

The preceding notation is also used in the slightly more general case of partial label assignments to arbitrarily chosen subsets of the set of positions . Formally, let {\mathbf{y}}_{\mathcal{S}} denote \left\{(i,{y}_{i})\phantom{\rule{2.77626pt}{0ex}}|\phantom{\rule{2.77626pt}{0ex}}i\in \mathcal{S},\phantom{\rule{2.77626pt}{0ex}}{y}_{i}\in \{\text{I},\text{N}\}\right\}. Given two partial assignments {\mathbf{y}}_{{\mathcal{S}}_{1}} and {\mathbf{y}}_{{\mathcal{S}}_{2}} are identical on {\mathcal{S}}_{1}\cap {\mathcal{S}}_{2}, the union {\mathbf{y}}_{{\mathcal{S}}_{1}}\cup {\mathbf{y}}_{{\mathcal{S}}_{2}} is well-defined.

The conditional distribution function of our pCRF (**X**, **Y**) with respect to the neighborhood graph \mathcal{G}=(\mathcal{V},\mathcal{E}) is defined as follows:

\begin{array}{ll}\mathbb{P}\left(\mathbf{y}\right|\mathbf{x})& =\frac{1}{Z\left(\mathbf{x}\right)}exp\left(\sum _{i\in \mathcal{V}}{\Phi}_{i}(\phantom{\rule{0.5pt}{0ex}}{y}_{i},\mathbf{x})+\sum _{\left\{i,j\right\}\in \mathcal{E}}{\Phi}_{i,j}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{i},{y}_{j},\mathbf{x}\right)\right.\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\left(\right)close=")">+\sum _{c\in \mathcal{C}\setminus (\mathcal{V}\cup \mathcal{E})}{\Phi}_{c}({\mathbf{y}}_{c},\mathbf{x})& ,\phantom{\rule{2em}{0ex}}\end{array}\n

(1)

where **x** and **y** are arbitrarily chosen instances of the random observation **X** and the random label sequence **Y**, respectively, *Φ*_{
c
}(*y*_{
c
},**x**)∈∙ (c\in \mathcal{C}) is the feature of the CRF located at the node clique *c* (again *Φ*_{
i
} and *Φ*_{i,j} simplify notation for *Φ*_{{i}} and *Φ*_{{i,j}}), and *Z*(**x**) is the observation-specific *normalization factor* defined by

\begin{array}{ll}Z\left(\mathbf{x}\right)& :=\sum _{\mathbf{y}\in {\left\{\text{I},\text{N}\right\}}^{n}}exp\left(\sum _{i\in \mathcal{V}}{\Phi}_{i}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{i},\mathbf{x}\right)+\sum _{\left\{i,j\right\}\in \mathcal{E}}{\Phi}_{i,j}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{i},{y}_{j},\mathbf{x}\right)\right.\phantom{\rule{2em}{0ex}}\\ \phantom{\rule{1em}{0ex}}\left(\right)close=")">+\sum _{c\in \mathcal{C}\setminus (\mathcal{V}\cup \mathcal{E})}{\Phi}_{c}({\mathbf{y}}_{c},\mathbf{x})& .\phantom{\rule{2em}{0ex}}\end{array}\n

(2)

Let us call ln\left(Z\right(\mathbf{x}\left)\mathbb{P}\right(\mathbf{y}\phantom{\rule{0.3em}{0ex}}\mid \phantom{\rule{0.3em}{0ex}}\mathbf{x}\left)\right) the *score* of the label sequence **y** given the observation **x**.

A CRF is called a *pairwise CRF* (pCRF) if *Φ*_{
c
}≡0, for all node cliques *c* larger than two. The remaining features *Φ*_{
i
} and *Φ*_{i,j} are referred to as *node features* and *edge features*, respectively. Thus, every position i\in \mathcal{V} and every edge (i,j)\in \mathcal{E} is represented by the pair (*Φ*_{
i
}(N,**x**),*Φ*_{
i
}(I,**x**)) and by the quadruplet (*Φ*_{{i,j}} (N,N,**x**),*Φ*_{{i,j}}(I,N,**x**),*Φ*_{{i,j}}(N,I,**x**),*Φ*_{{i,j}}(I,I,**x**)).

Following [30], we assume moreover that each node feature and each edge feature is a sum of weighted base features. More precisely, for every position i\in \mathcal{V} and every edge \{i,j\}\in \mathcal{E} we assume representations

\begin{array}{ll}\hfill {\Phi}_{i}(\phantom{\rule{0.5pt}{0ex}}{y}_{i},\mathbf{x})& =\sum _{k=1}^{{K}_{1}}{\alpha}_{k}{\psi}_{k}(i,{y}_{i},\mathbf{x})\\ \hfill {\Phi}_{i,j}(\phantom{\rule{0.5pt}{0ex}}{y}_{i},{y}_{j},\mathbf{x})& =\sum _{k=1}^{{K}_{2}}{\beta}_{k}{\varphi}_{k}(i,j,{y}_{i},{y}_{j},\mathbf{x}),\end{array}

where **y**∈{I,N}^{n} and **x** is an observation. The two real vectors

\mathbf{\alpha}:=\left({\alpha}_{1},{\alpha}_{2},\dots ,{\alpha}_{{K}_{1}}\right)\phantom{\rule{1em}{0ex}}\mathbf{\beta}:=\left({\beta}_{1},{\beta}_{2},\dots ,{\beta}_{{K}_{2}}\right)

(3)

need to be calculated in a training phase.

In the most general sense, protein characteristics are real-valued evaluations of positions and pairs of adjacent positions (edges of the neighborhood graph), respectively, that are correlated with our position labeling problem. We use a standard step function technique to obtain base features from protein characteristics, rather than taking the raw values of the characteristics. To make our paper self-contained, let us describe this technique for short.

A protein characteristic depends on the observation and either a node or an edge. Each protein characteristic, such as e.g. the relative solvent-accessible surface area of a residue, is transformed into several binary features by binning, i.e. we distinguish only a few different cases rather than the whole range of the characteristic. Assuming the common case of real-valued characteristics, the bins are a partition of the reals into intervals. The use of this discretization allows to approximate any shape of dependency of the labels on the characteristics, rather than assuming a fixed shape such as linear or logarithmic.

*From protein characteristics for positions to node features.* We subdivide the range of the characteristics *C* into say *γ* intervals, where *γ* is at least two. Let *s*_{1}<*s*_{2}<…<*s*_{γ−1} be the corresponding interval boundaries. It is reasonable to take *s*_{
ι
} as the *ι*/*γ*-quantile of the empirical distribution of *C* for non-interface residues, where *C*(*i*,**x**)∈(*s*_{0},*s*_{
γ
}]. Then we define for each position i\in \mathcal{V} the following 2*γ* base features associated with the position characteristics *C*.

\phantom{\rule{-15.0pt}{0ex}}{\varphi}_{y,\iota}^{\left(C\right)}(i,{y}_{i},\mathbf{x}):=\left\{\begin{array}{ll}1& \phantom{\rule{2em}{0ex}}\text{if}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{y}_{i}=y\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\text{and}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}C(i,\mathbf{x})\in ({s}_{\iota},{s}_{\iota +1}];\\ 0& \phantom{\rule{2em}{0ex}}\text{otherwise;}\end{array}\right.

(4)

where *y*=N,I, and *ι*=0,1,…,*γ*−1 and *s*_{0}:=−*∞*,*s*_{
γ
}:=*∞*.

*From protein characteristics for edges to edge features.* Let *D* be the characteristics. Analogous to the previous case, we then obtain for each edge \{i,j\}\in \mathcal{E} the following 4*γ* base features associated with *D*, where *y*,*y*^{′}∈{N,I} and *ι*=0,1,…,*γ*−1.

\phantom{\rule{-15.0pt}{0ex}}{\varphi}_{y,{y}^{\prime},\iota}^{\left(D\right)}(i,j,{y}_{i},{y}_{j},\mathbf{x})\phantom{\rule{0.3em}{0ex}}:=\phantom{\rule{0.3em}{0ex}}\left\{\phantom{\rule{0.3em}{0ex}}\begin{array}{ll}1& \phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\text{if}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{y}_{i}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}y,{y}_{j}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}{y}^{\prime}\phantom{\rule{0.3em}{0ex}},\text{and}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}D(i,j,\mathbf{x})\phantom{\rule{0.3em}{0ex}}\in \phantom{\rule{0.3em}{0ex}}({s}_{\iota},{s}_{\iota +1}]\phantom{\rule{0.3em}{0ex}};\\ 0& \phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\text{otherwise.}\end{array}\right.

(5)

In both cases we set *γ*=5.

### Devising a generalized Viterbi algorithm for pCRFs

The problem of finding a most probable label sequence **y**^{∗} given an observation **x** is **NP**-hard for general pCRFs [31]. In this subsection we present a heuristic that approximately solves this problem.

To this end, we first devise an algorithm, which we call *generalized Viterbi algorithm*. It computes an optimal label sequence, where the posterior probability of **y**^{∗} given **x** is maximized. Unfortunately, its run-time is in too many cases not acceptable. That is why we transform it in a second step into a feasible, time-bounded approximation algorithm.

#### The generalized Viterbi algorithm

Let \mathcal{G}=(\mathcal{V},\mathcal{E}) be the neighborhood graph underlying the protein under study. For any assignment (label sequence) **y** and any subset {\mathcal{V}}^{\prime} of , let {\mathbf{y}}_{{\mathcal{V}}^{\prime}} denote the partial assignment of **y** with respect to {\mathcal{V}}^{\prime}. (This is in line with the notation **y**_{
c
} (*c* a position clique) introduced earlier in this study).

If {\mathcal{V}}_{1},{\mathcal{V}}_{2},\dots ,{\mathcal{V}}_{r} are pairwise disjoint position sets, the assignment for {\mathcal{V}}_{1}\cup {\mathcal{V}}_{2}\cup \dots \cup {\mathcal{V}}_{r} canonically resulting from assignments {\mathbf{y}}_{{\mathcal{V}}_{1}},{\mathbf{y}}_{{\mathcal{V}}_{2}},\dots ,{\mathbf{y}}_{{\mathcal{V}}_{r}} is denoted by {\mathbf{y}}_{{\mathcal{V}}_{1}}\cup {\mathbf{y}}_{{\mathcal{V}}_{2}}\cup \dots \cup {\mathbf{y}}_{{\mathcal{V}}_{r}}. For {\mathcal{V}}^{\prime}\subset \mathcal{V}, the score \mathrm{s}{\mathcal{V}}^{\prime}({\mathbf{y}}_{{\mathcal{V}}^{\prime}}\phantom{\rule{0.3em}{0ex}}\mid \phantom{\rule{0.3em}{0ex}}\mathbf{x}) is defined by

\begin{array}{l}{\mathrm{s}}_{{\mathcal{V}}^{\prime}}({\mathbf{y}}_{{\mathcal{V}}^{\prime}}\phantom{\rule{0.3em}{0ex}}\mid \phantom{\rule{0.3em}{0ex}}\mathbf{x}):=\sum _{i\in {\mathcal{V}}^{\prime}}{\Phi}_{i}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{i},\mathbf{x}\right)+\sum _{\begin{array}{c}i,\phantom{\rule{0.5pt}{0ex}}j\in {\mathcal{V}}^{\prime}\\ \{i,\phantom{\rule{0.5pt}{0ex}}j\}\in \mathcal{E}\end{array}}{\Phi}_{i,j}\left({y}_{i},{y}_{j},\mathbf{x}\right).\end{array}

Then the problem of determining a most probable label sequence **y**^{∗} given an observation **x** can be reformulated as

\begin{array}{l}{\mathbf{y}}^{\ast}=\underset{\mathbf{y}}{\text{argmax}}\phantom{\rule{2.77626pt}{0ex}}{\mathrm{s}}_{\mathcal{V}}(\mathbf{y}\phantom{\rule{0.3em}{0ex}}\mid \phantom{\rule{0.3em}{0ex}}\mathbf{x}).\end{array}

This is the case, because it suffices to consider the score.

To put this into practice, we devised an algorithm we call generalized Viterbi. On the one hand, it is analogous to the classical Viterbi algorithm. On the other hand, there is a major difference. In our case there is no canonical order in which the positions of are traversed. Having explained our algorithm for any order, we show how to calculate a fairly effective one. In what follows, we assume that the positions not yet touched are held in a dynamic queue. Those positions having already left the queue form the *history set*\mathcal{\mathscr{H}}\subseteq \mathcal{V}.

Assume that the subgraph of induced by has connected components {\mathcal{\mathscr{H}}}_{1},{\mathcal{\mathscr{H}}}_{2}, …, {\mathcal{\mathscr{H}}}_{m}. For *μ*=1,2,…,*m*, let {\mathcal{\mathcal{B}}}_{\mu}\subseteq {\mathcal{\mathscr{H}}}_{\mu} be the so-called *boundary component* associated with {\mathcal{\mathscr{H}}}_{\mu} defined by {\mathcal{\mathcal{B}}}_{\mu}:=\left\{i\in {\mathcal{\mathscr{H}}}_{\mu}\phantom{\rule{2.77626pt}{0ex}}\left|\phantom{\rule{2.77626pt}{0ex}}\exists \phantom{\rule{2.77626pt}{0ex}}j\notin \mathcal{\mathscr{H}},\phantom{\rule{0.3em}{0ex}}\{i,j\}\in \mathcal{E}\right.\right\}. The complement {\mathcal{\mathscr{H}}}_{\mu}\phantom{\rule{0.3em}{0ex}}\setminus \phantom{\rule{0.3em}{0ex}}{\mathcal{\mathcal{B}}}_{\mu} is the *interior* of the *μ*-th history component. See Figure 1 for an example.

For assignments {\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{1}},{\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{2}},\dots ,{\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{m}} of the boundary components {\mathcal{\mathcal{B}}}_{1},{\mathcal{\mathcal{B}}}_{2},\dots ,{\mathcal{\mathcal{B}}}_{m}, the Viterbi variables {\text{vit}}_{{\mathcal{\mathscr{H}}}_{1}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{1}}\right),{\text{vit}}_{{\mathcal{\mathscr{H}}}_{2}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{2}}\right),\dots ,{\text{vit}}_{{\mathcal{\mathscr{H}}}_{m}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{m}}\right) are defined as

\begin{array}{ll}{\text{vit}}_{{\mathcal{\mathscr{H}}}_{\mu}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{\mu}}\right)& :=\underset{{\mathbf{y}}_{{\mathcal{\mathscr{H}}}_{\mu}\setminus {\mathcal{\mathcal{B}}}_{\mu}}}{max}{\mathrm{s}}_{{\mathcal{\mathscr{H}}}_{\mu}}\left({\mathbf{y}}_{{\mathcal{\mathscr{H}}}_{\mu}\setminus {\mathcal{\mathcal{B}}}_{\mu}}\cup {\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{\mu}}\phantom{\rule{0.3em}{0ex}}\mid \phantom{\rule{0.3em}{0ex}}\mathbf{x}\right)\\ \phantom{\rule{1em}{0ex}}\times (\mu =1,2,\dots ,m).\end{array}

(6)

The Viterbi variables can be represented as a set of tables, one table of size {2}^{\left|{\mathcal{\mathcal{B}}}_{\mu}\right|} for each boundary component {\mathcal{\mathcal{B}}}_{\mu}. In the case where a boundary component is empty the table reduces to a single number.

At any stage, the algorithm stores the connected components {\mathcal{\mathscr{H}}}_{1},{\mathcal{\mathscr{H}}}_{2}, …, {\mathcal{\mathscr{H}}}_{m} of the current history set , the corresponding boundary components {\mathcal{\mathcal{B}}}_{1},{\mathcal{\mathcal{B}}}_{2}, …, {\mathcal{\mathcal{B}}}_{m}, and Viterbi variable values {\text{vit}}_{{\mathcal{\mathscr{H}}}_{1}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{1}}\right),{\text{vit}}_{{\mathcal{\mathscr{H}}}_{2}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{2}}\right),\dots ,{\text{vit}}_{{\mathcal{\mathscr{H}}}_{m}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{m}}\right), where {\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{1}},{\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{2}},\dots ,{\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{m}} range over all possible assignments of corresponding boundary component. We store for every assignment on the boundary, a maximizing interior assignment. This assignment is the argmax of (6) but is determined with the dynamic programming recursions defined below. Let us call these data the current state of the algorithm. It mainly consists of record sets indexed by the boundary labelings.

At the very beginning the queue contains all positions, the history set and the corresponding boundary component are empty. As long as the position queue is not empty, the top element *v* is extracted and the state is updated as follows.

Adjoining *v* to the history set , there are two cases to distinguish. Either position *v* is not adjacent to any other position of any old boundary component (see Figure 2) or adjoining position *v* to results in adding it to some connected component of the old history set or even merging together two or more of them (see Figure 3).

In the first case we simply have to take over all the old connected components, boundary sets and Viterbi variables. Moreover, we perform the instructions

\phantom{\rule{-10.0pt}{0ex}}\begin{array}{ll}{\mathcal{\mathscr{H}}}_{m+1}& \leftarrow {\mathcal{\mathcal{B}}}_{m+1}\leftarrow \left\{v\right\},\phantom{\rule{1em}{0ex}}{\text{vit}}_{{\mathcal{\mathscr{H}}}_{m+1}}\left(\text{N}\right)\leftarrow {\mathrm{s}}_{{\mathcal{\mathscr{H}}}_{m+1}}(\text{N}\mid \mathbf{x}),\\ {\text{vit}}_{{\mathcal{\mathscr{H}}}_{m+1}}\left(\text{I}\right)\leftarrow {\mathrm{s}}_{{\mathcal{\mathscr{H}}}_{m+1}}(\text{I}\mid \mathbf{x}).\end{array}

In the second case position *v* is adjacent to some boundary components, say {\mathcal{\mathcal{B}}}_{{m}^{\prime}},{\mathcal{\mathcal{B}}}_{{m}^{\prime}+1},\dots ,{\mathcal{\mathcal{B}}}_{m}. Then the old history components {\mathcal{\mathscr{H}}}_{{m}^{\prime}},{\mathcal{\mathscr{H}}}_{{m}^{\prime}+1},\dots ,{\mathcal{\mathscr{H}}}_{m} and the current position *v* are merged together:

{\mathcal{\mathscr{H}}}_{\mathit{\text{tmp}}}\leftarrow {\mathcal{\mathscr{H}}}_{{m}^{\prime}}\cup {\mathcal{\mathscr{H}}}_{{m}^{\prime}+1}\cup \dots \cup {\mathcal{\mathscr{H}}}_{m}\cup \left\{v\right\}.

The other history set components and corresponding Viterbi variables are not affected.

For *μ*=*m*^{′},*m*^{′}+1,…,*m*, let {\mathcal{R}}_{\mu}\subseteq {\mathcal{\mathcal{B}}}_{\mu} be the set of all positions out of {\mathcal{\mathcal{B}}}_{\mu} that are no longer boundary nodes after having adjoined *v* to the history set. The nodes in {\mathcal{R}}_{\mu} are removed from the boundary {\mathcal{\mathcal{B}}}_{\mu} after the iteration. Let {\stackrel{~}{\mathcal{\mathcal{B}}}}_{\mu} be the complement of {\mathcal{R}}_{\mu} in {\mathcal{\mathcal{B}}}_{\mu}. By inspecting the edges incident to the current position *v*, all these sets can be computed in linear time.

The new boundary set {\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}} is then either {\stackrel{~}{\mathcal{\mathcal{B}}}}_{{m}^{\prime}}\cup {\stackrel{~}{\mathcal{\mathcal{B}}}}_{{m}^{\prime}+1}\cup \dots \cup {\stackrel{~}{\mathcal{\mathcal{B}}}}_{m} or {\stackrel{~}{\mathcal{\mathcal{B}}}}_{{m}^{\prime}}\cup {\stackrel{~}{\mathcal{\mathcal{B}}}}_{{m}^{\prime}+1}\cup \dots \cup {\stackrel{~}{\mathcal{\mathcal{B}}}}_{m}\cup \left\{v\right\}, where it can be checked in linear time whether or not *v* is a new boundary position.

We are now in a position to calculate the new Viterbi variables {\text{vit}}_{{\mathcal{\mathscr{H}}}_{\mathit{\text{tmp}}}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}}}\right), where {\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}}} ranges over all assignments of the new boundary set {\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}}.

If v\notin {\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}} then

\phantom{\rule{-16.0pt}{0ex}}\begin{array}{ll}{\text{vit}}_{{\mathcal{\mathscr{H}}}_{\mathit{\text{tmp}}}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}}}\right)& \leftarrow \underset{{y}_{v}}{max}\left\{{\Phi}_{v}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{v},\mathbf{x}\right)+\sum _{\mu ={m}^{\prime}}^{m}\underset{{\mathbf{y}}_{{\mathcal{R}}_{\mu}}}{max}\right.\\ \phantom{\rule{1em}{0ex}}\left(\right)close="\}">\phantom{\rule{0.3em}{0ex}}\times \left(\phantom{\rule{0.3em}{0ex}}{\text{vit}}_{{\mathcal{\mathscr{H}}}_{\mu}}{\mathbf{y}}_{{\stackrel{~}{\mathcal{\mathcal{B}}}}_{\mu}}\phantom{\rule{0.3em}{0ex}}\cup {\mathbf{y}}_{{\mathcal{R}}_{\mu}}\phantom{\rule{0.3em}{0ex}}+\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\sum _{\begin{array}{c}w\in {\mathcal{\mathcal{B}}}_{\mu}\\ \{v,w\}\in \mathcal{E}\end{array}}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{\Phi}_{v,w}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{v},{y}_{w},\mathbf{x}\right)\phantom{\rule{0.3em}{0ex}}\right)\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}& \phantom{\rule{0.3em}{0ex}}.\end{array}\n

Here, any assignment of a node set is assumed to implicitly define assignments for any subset thereof. Figure 4 illustrates this case of the recursion step. If, however, v\in {\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}}, then

\phantom{\rule{-15.0pt}{0ex}}\begin{array}{ll}{\text{vit}}_{{\mathcal{\mathscr{H}}}_{\mathit{\text{tmp}}}}\left({\mathbf{y}}_{{\mathcal{\mathcal{B}}}_{\mathit{\text{tmp}}}}\right)\leftarrow {\Phi}_{v}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{v},\mathbf{x}\right)& +\sum _{\begin{array}{c}w\in {\stackrel{~}{\mathcal{\mathcal{B}}}}_{{\mu}^{\prime}}\cup \cdots \cup {\stackrel{~}{\mathcal{\mathcal{B}}}}_{\mu}\\ (v,w)\in \mathcal{E}\end{array}}{\Phi}_{v,w}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{v},{y}_{w},\mathbf{x}\right)\\ +\sum _{\mu ={m}^{\prime}}^{m}\phantom{\rule{0.3em}{0ex}}\left\{\phantom{\rule{0.3em}{0ex}}\underset{{\mathbf{y}}_{{\mathcal{R}}_{\mu}}}{max}\phantom{\rule{0.3em}{0ex}}\left(\phantom{\rule{0.3em}{0ex}}{\text{vit}}_{{\mathcal{\mathscr{H}}}_{\mu}}\left({\mathbf{y}}_{{\stackrel{~}{\mathcal{\mathcal{B}}}}_{\mu}}\cup {\mathbf{y}}_{{\mathcal{R}}_{\mu}}\right)\right.\right.\\ +\left(\right)close="\}">\left(\right)close=")">\sum _{\begin{array}{c}w\in {\mathcal{R}}_{\mu}\\ (v,w)\in \mathcal{E}\end{array}}{\Phi}_{v,w}\left(\phantom{\rule{0.5pt}{0ex}}{y}_{v},{y}_{w},\mathbf{x}\right)\\ .\end{array}\n

Finally, the interior labeling is stored, where the maximum is attained. The algorithm terminates after the last node *v* from has been processed. In the typical case, where the graph is connected, at termination m=1,{\mathcal{\mathscr{H}}}_{1}=\mathcal{V},{\mathcal{\mathcal{B}}}_{1}=\varnothing.

The running time of the algorithm is \mathcal{O}\left(n{2}^{b}\right), where *b* is the size of the largest boundary set and *n* is the number of surface residues. We call this algorithm *generalized Viterbi* algorithm as for the case of a graph that is a linear chain 1−2−3−⋯−*n* of nodes using the node order 1,2,…,*n* the Viterbi variables we define are the same as in the standard Viterbi algorithm for HMMs. In the case of a graph that is a tree, this algorithm specializes to the Fitch algorithm or an argmax-version of Felsenstein’s pruning algorithm when a leaf-to-root node order is chosen after rooting the tree at an arbitrary node. In both special cases the boundary sets always have size at most 1. The tree example also motivate the use of several history sets at the same time: using a single history set only, one would not be able to achieve a linear running time on trees.

#### A heuristic based on the generalized Viterbi algorithm

First, it is vital for our generalized Viterbi algorithm to keep the size of the boundary sets small. A good position order is here of great importance. The algorithm starts by choosing a vertex of minimal degree. When determining the next position to be dequeued, the algorithm selects a boundary node such that the number of incident edges leading to nodes not belonging to any current history set is minimal. In an arbitrarily chosen order these nodes are dequeued next.

Second, the space demand is reduced by restricting the number of boundary labelings admitted. Starting from the available labelings of the current history set, the percentage of the reachable boundary labelings of the successor history that will be discarded is calculated. Then the corresponding percentile is estimated. To this end, a sufficiently large sample of possible labelings of the new boundary set is drawn, the Viterbi variables are computed, and the corresponding sample percentile is taken. Finally, only those boundary labelings of the new history set are retained whose Viterbi variables exceed this percentile.

That way we compute near-optimal solutions good enough for our purposes within feasible computation time.

### Piecewise training for pCRFs

Let

\mathcal{D}:=\left(\left({\mathbf{x}}^{\left(1\right)},{\mathbf{y}}^{\left(1\right)}\right),\left({\mathbf{x}}^{\left(2\right)},{\mathbf{y}}^{\left(2\right)}\right),\dots ,\left({\mathbf{x}}^{\left(m\right)},{\mathbf{y}}^{\left(m\right)}\right)\right)

be the independent identically distributed training sample. For every *μ*=1,2,…,*m*, let {\mathcal{V}}_{\mu} and {\mathcal{E}}_{\mu} be the set of positions and edges in the neighborhood graph associated with **x**_{
μ
}, let {n}_{\mu}=\left|{\mathcal{V}}_{\mu}\right| be the number of positions of the *μ*-th training example and let {\{\text{I},\text{N}\}}^{{n}_{\mu}} be the set of all possible label sequences of this graph.

This data set is unbalanced as there are many more non-interface positions as interface positions. As customary for other machine learning approaches such as support vector machines and artificial neural networks [28], we here manipulated the ratio of positive and negative example positions for training in order to obtain reasonable results.

We have amplified the influence of the positive examples, rather than selecting various sets of training data by deleting negative ones as done in [28].

Let *ν*_{
I
}, *ν*_{
N
}, *ν*_{
II
} and *ν*_{
NN
} be the number of interface positions, the number of non-interface positions, the number of interface-interface edges, and the number of non-interface-non-interface edges in , respectively. Then we define the following two *amplifier functions* for all positions *i* and for all edges {*i*,*j*} of the *m* neighborhood graphs resulting from the training data .

\begin{array}{ll}\hfill {\eta}_{1}\left(i\right):& =\left\{\begin{array}{c}\frac{{\nu}_{N}}{{\nu}_{I}}-1\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\text{if}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{y}_{i}=\text{I};\\ 0\phantom{\rule{2em}{0ex}}\phantom{\rule{1em}{0ex}}\text{if}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{y}_{i}=\text{N}.\end{array}\right.\\ \hfill {\eta}_{2}(i,j)& :=\left\{\begin{array}{c}\frac{{\nu}_{\mathit{\text{NN}}}}{{\nu}_{\mathit{\text{II}}}}-1\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\text{if}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{y}_{i}={y}_{j}=\text{I};\\ \frac{{\nu}_{N}}{{\nu}_{I}}-1\phantom{\rule{1em}{0ex}}\text{if}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{y}_{i}\ne {y}_{j};\\ 0\phantom{\rule{2em}{0ex}}\phantom{\rule{1em}{0ex}}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\text{if}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}{y}_{i}={y}_{j}=\text{N}.\end{array}\right.\end{array}

To uniformly govern the influence of the amplifiers, we introduce an *amplifier control parameter* *η*_{3}∈ [ 0,1].

We set up our two log-likelihood objective function by

\phantom{\rule{-16.0pt}{0ex}}\begin{array}{ll}\hfill \ell \phantom{\rule{0.3em}{0ex}}\left({\lambda}^{\left(s\right)},{\eta}_{3}\right)\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}:& =\phantom{\rule{0.3em}{0ex}}\sum _{\mu =1}^{m}\sum _{i\in {\mathcal{V}}_{\mu}}\phantom{\rule{0.3em}{0ex}}\left(1+{\eta}_{3}{\eta}_{1}\left(i\right)\right)\sum _{k=1}^{{K}_{1}}{\alpha}_{k}{\psi}_{k}\phantom{\rule{0.3em}{0ex}}\left(i,{y}_{i}^{\left(\mu \right)},{\mathbf{x}}^{\left(\mu \right)}\right)\\ \phantom{\rule{1em}{0ex}}+\sum _{\mu =1}^{m}\sum _{\{i,j\}\in {\mathcal{E}}_{\mu}}\left(1+{\eta}_{3}{\eta}_{2}(i,\phantom{\rule{0.1pt}{0ex}}j)\right)\sum _{k=1}^{{K}_{2}}{\beta}_{k}{\varphi}_{k}\\ \phantom{\rule{1em}{0ex}}\times \left(i,j,{y}_{i}^{\left(\mu \right)},{y}_{j}^{\left(\mu \right)},{\mathbf{x}}^{\left(\mu \right)}\right)-\sum _{\mu =1}^{m}lnZ\left({\mathbf{x}}^{\left(\mu \right)},{\eta}_{3}\right)\phantom{\rule{0.3em}{0ex}},\end{array}

where ideally for each *μ*=1,2,…,*m*

\phantom{\rule{-16.0pt}{0ex}}\begin{array}{ll}Z\phantom{\rule{0.3em}{0ex}}\left({\mathbf{x}}^{\left(\mu \right)},{\eta}_{3}\right)\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}& :=\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\sum _{\mathbf{y}\in {\{\text{I},\text{N}\}}^{{n}_{\mu}}}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}exp\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\left(\sum _{i\in {\mathcal{V}}_{\mu}}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\left(1+{\eta}_{3}{\eta}_{1}\left(i\right)\right)\phantom{\rule{0.3em}{0ex}}\sum _{k=1}^{{K}_{1}}\phantom{\rule{0.3em}{0ex}}{\alpha}_{k}{\psi}_{k}\phantom{\rule{0.3em}{0ex}}\left(i,{y}_{i},{\mathbf{x}}^{\left(\mu \right)}\right)\right.\\ \phantom{\rule{1em}{0ex}}\left(\right)close=")">+\sum _{\{i,j\}\in {\mathcal{E}}_{\mu}}\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\left(1+{\eta}_{3}{\eta}_{2}(i,j)\right)\phantom{\rule{0.3em}{0ex}}\sum _{k=1}^{{K}_{2}}{\beta}_{k}{\varphi}_{k}\phantom{\rule{0.3em}{0ex}}\left(i,j,{y}_{i},{y}_{j},{\mathbf{x}}^{\left(\mu \right)}\right)\phantom{\rule{0.3em}{0ex}}\end{array}\n

is the training-instance-specific normalization factor.

Unfortunately, maximizing this objective function in general is algorithmically intractable. Taking pattern from Sutton *et al.*[35] who introduced what they called piecewise training, we deal with this problem by disentangling the labels of nodes and edges. For *μ*=1,2,…,*m*, a *non-coherent labeling*\mathbf{y}\in {\{\text{I},\text{N}\}}^{{\mathcal{V}}_{\mu}\times {\mathcal{E}}_{\mu}} of the neighborhood graph \left({\mathcal{V}}_{\mu},{\mathcal{E}}_{\mu}\right) is any mapping that assigns to every position v\in {\mathcal{V}}_{\mu} and every edge e\in {\mathcal{E}}_{\mu} a label **y**_{
v
}∈{I,N} and a pair of labels **y**_{
e
}∈{I,N}^{2}, respectively.

We then replace *Z*(**x**^{(μ)},*η*_{3}) by

\phantom{\rule{-16.0pt}{0ex}}\begin{array}{ll}\stackrel{~}{Z}\phantom{\rule{0.3em}{0ex}}\left({\mathbf{x}}^{\left(\mu \right)},{\eta}_{3}\right)\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}& :=\phantom{\rule{0.3em}{0ex}}\sum _{\mathbf{y}\in {\{\text{I},\text{N}\}}^{{\mathcal{V}}_{\mu}\times {\mathcal{E}}_{\mu}}}\phantom{\rule{0.3em}{0ex}}exp\phantom{\rule{0.3em}{0ex}}\phantom{\rule{0.3em}{0ex}}\left(\sum _{v\in {\mathcal{V}}_{\mu}}\phantom{\rule{0.3em}{0ex}}\left(1+{\eta}_{3}{\eta}_{1}\left(v\right)\right)\phantom{\rule{0.3em}{0ex}}\sum _{k=1}^{{K}_{1}}{\alpha}_{k}{\psi}_{k}\right.\\ \phantom{\rule{1em}{0ex}}\times \left(v,{\mathbf{y}}_{v},{\mathbf{x}}^{\left(\mu \right)}\right)+\sum _{e\in {\mathcal{E}}_{\mu}}\left(1+{\eta}_{3}{\eta}_{2}\left(e\right)\right)\sum _{k=1}^{{K}_{2}}{\beta}_{k}{\varphi}_{k}\\ \phantom{\rule{1em}{0ex}}\times \left(\right)close=")">\left(e,{\mathbf{y}}_{e},{\mathbf{x}}^{\left(\mu \right)}\right)\end{array}\n

as normalization factor. This makes the optimization problem computationally feasible.

The L-BFGS method [38] is used to solve it. That way we obtain the coefficient vectors **α** and **β** (see Equations 3), which depend on the amplifier control parameter *η*_{3}∈ [ 0,1].

To mitigate the negative consequences of disentanglement, we use a *correction factor* *δ*≥1. For any characteristics *D* and *ι*=0,1,…,*γ*−1, the weights of the bases edge features {\varphi}_{\text{I},\text{I},\iota}^{\left(D\right)} and {\varphi}_{\text{N},\text{N},\iota}^{\left(D\right)} (see Equation 5) are all multiplied by *δ*. Thus a change in classification along an edge is additionally penalized. The correction factor *δ* is set best between 1.15 and 1.25.

For our implementation of the training, we used the Java CRF package from Sunita Sarawagi at http://crf.sourceforge.net/.