Previous Query
Next Query
Heavy atom contact count
with Neighboring_Residues (res1, res2, [time]) as (
select distinct residue_number_x, residue_number_y, [time] from
(select
a.residue_number as residue_number_x, a.residue as residue_x, a.atom_number as atom_number_x, a.atom_name as atom_name_x,
b.residue_number as residue_number_y, b.residue as residue_y, b.atom_number as atom_number_y, b.atom_name as atom_name_y,
POWER( (b.x_coord - a.x_coord) * (b.x_coord - a.x_coord)+
(b.y_coord - a.y_coord) * (b.y_coord - a.y_coord)+
(b.z_coord - a.z_coord) * (b.z_coord - a.z_coord),
0.5) as distance,
a.step as step
from
dbo.[vCoord_678] a
inner join dbo.[vCoord_678] b
on a.step = b.step and
a.[vid] = b.[vid] and
a.[pid] = b.pid and
a.[temp] = b.temp and
a.[run] = b.run and
a.[cid] = b.cid
where
a.atom_name = 'ca' and
b.atom_name = 'ca' and
a.step <= 5000 and
a.[Run] = 1 and
a.[Temp] =498 and
a.[Conditions] = 'cs=.4,nbcycl=3,cor=8' and
a.atom_number < b.atom_Number
) ca_dist
where distance < 10.0
)
select residue_number_x, atom_name_x, residue_number_y, atom_name_y, count(*) as timecounts from
(select
a.residue_number as residue_number_x, a.residue as residue_x, a.atom_number as atom_number_x, a.atom_name as atom_name_x,
b.residue_number as residue_number_y, b.residue as residue_y, b.atom_number as atom_number_y, b.atom_name as atom_name_y,
POWER( (b.x_coord - a.x_coord) * (b.x_coord - a.x_coord)+
(b.y_coord - a.y_coord) * (b.y_coord - a.y_coord)+
(b.z_coord - a.z_coord) * (b.z_coord - a.z_coord),
0.5) as distance
from
dbo.[vCoord_678] a
inner join dbo.[vCoord_678] b
on a.step = b.step and
a.[vid] = b.[vid] and
a.[pid] = b.pid and
a.[temp] = b.temp and
a.[run] = b.run and
a.[cid] = b.cid
inner join Neighboring_Residues n
on n.res1 = a.Residue_Number and
n.res2 = b.Residue_Number and
n.step = a.step
where
a.atom_type = 1 and
b.atom_type = 1 and
a.[time] <= 1000 and
a.[Run] = 1 and
a.[Temp] =498 and
a.[Conditions] = 'cs=.4,nbcycl=3,cor=8' and
a.atom_number < b.atom_Number
) ca_dist
where distance <
(case when substring(atom_name_x,1,1) = 'C' and
substring(atom_name_y,1,1) = 'C'
then 5.4 else 4.6 end)
group by residue_number_x, atom_name_x, residue_number_y, atom_name_y