Calculating fraction of native contacts, with a distance lower than or equal to the reference structure¶

contacts.Contacts supports each of the three methods explained above. It must be defined with a selection of two groups that change over time. The fraction of native contacts present in selection are with respect to contacts found in refgroup: two contacting groups in a reference configuration. Native contacts are found in the reference group refgroup based on the radius.

Below, we just use the atomgroups in the universe at the current frame as a reference.

The results are available as a numpy array at ca1.timeseries. The first column is the frame, and the second is the fraction of contacts present in that frame.

[5]:

ca1_df=pd.DataFrame(ca1.timeseries,columns=['Frame','Contacts from first frame'])ca1_df.head()

[5]:

Frame

Contacts from first frame

0

0.0

1.000000

1

1.0

0.492754

2

2.0

0.449275

3

3.0

0.507246

4

4.0

0.463768

Note that the data is presented as fractions of the native contacts present in the reference configuration. In order to find the number of contacts present, multiply the data with the number of contacts in the reference configuration. Initial contact matrices are saved as pairwise arrays in ca1.initial_contacts.

[6]:

ca1.initial_contacts[0].shape

[6]:

(70, 44)

You can sum this to work out the number of contacts in your reference, and apply that to the fractions of references in your timeseries data.

[7]:

n_ref=ca1.initial_contacts[0].sum()print('There are {} contacts in the reference.'.format(n_ref))

Calculating fraction of native contacts, with pairs assigned based on a soft potential¶

refgroup can either be two contacting groups in a reference configuration, or a list of tuples of two contacting groups. Below, we set the reference trajectory to its last frame and select another pair of contacting atomgroups.