I managed to do this by creating a polydata and passing the required arrays to the polydata which I then passed to the vtkProteinRibbonFilter. To see what arrays vtkProteinRibbonFilter requires and their contents, refer to this post.
The code to send the arrays to the polydata (I haven’t included the code to parse PDB files which fills these arrays, if someone wants it, please let me know) -
output = vtk.vtkPolyData()
# for atom type
AtomType = np.array(AtomType)
atom_type = numpy_to_vtk(num_array=AtomType, deep=True, array_type=vtk.VTK_ID_TYPE)
atom_type.SetName("atom_type")
output.GetPointData().AddArray(atom_type)
# for atom type strings
atom_types = vtk.vtkStringArray()
atom_types.SetName("atom_types")
atom_types.SetNumberOfTuples(len(AtomTypeStrings))
for i in range(len(AtomTypeStrings)):
atom_types.SetValue(i, AtomTypeStrings[i])
AtomTypeStrings = np.array(AtomTypeStrings)
output.GetPointData().AddArray(atom_types)
# for residue
residue = numpy_to_vtk(num_array=Residue, deep=True, array_type=vtk.VTK_ID_TYPE)
residue.SetName("residue")
output.GetPointData().AddArray(residue)
# for chain
Chain = np.array(Chain)
chain = numpy_to_vtk(num_array=Chain, deep=True, array_type=vtk.VTK_UNSIGNED_CHAR)
chain.SetName("chain")
output.GetPointData().AddArray(chain)
# for secondary structures
s_s = numpy_to_vtk(num_array=SecondaryStructures, deep=True, array_type=vtk.VTK_UNSIGNED_CHAR)
s_s.SetName("secondary_structures")
output.GetPointData().AddArray(s_s)
# for secondary structures begin, required but not used by vtkProteinRibbonFilter, pass an array of ones
newarr = np.ones(n)
s_sb = numpy_to_vtk(num_array=newarr, array_type=vtk.VTK_UNSIGNED_CHAR)
s_sb.SetName("secondary_structures_begin")
output.GetPointData().AddArray(s_sb)
# for secondary structures end, required but not used by vtkProteinRibbonFilter, pass an array of ones
newarr = np.ones(n)
s_se = numpy_to_vtk(num_array=newarr, array_type=vtk.VTK_UNSIGNED_CHAR)
s_se.SetName("secondary_structures_end")
output.GetPointData().AddArray(s_se)
# for ishetatm
IsHetatm = np.array(IsHetatm)
ishetatm = numpy_to_vtk(num_array=IsHetatm, deep=True, array_type=vtk.VTK_UNSIGNED_CHAR)
ishetatm.SetName("ishetatm")
output.GetPointData().AddArray(ishetatm)
# for model
Model = np.array(Model)
model = numpy_to_vtk(num_array=Model, deep=True, array_type=vtk.VTK_UNSIGNED_INT)
model.SetName("model")
output.GetPointData().AddArray(model)
# for colors
rgb = vtk.vtkUnsignedCharArray()
rgb.SetNumberOfComponents(3)
rgb.Allocate(3 * NumberOfAtoms)
rgb.SetName("rgb_colors")
for i in range(NumberOfAtoms):
rgb.InsertNextTuple(table.GetDefaultRGBTuple(AtomType[i]))
output.GetPointData().SetScalars(rgb)
# for radii
Radii = vtk.vtkFloatArray()
Radii.SetNumberOfComponents(3)
Radii.Allocate(3 * NumberOfAtoms)
Radii.SetName("radius")
for i in range(NumberOfAtoms):
Radii.InsertNextTuple3(table.GetVDWRadius(AtomType[i]),
table.GetVDWRadius(AtomType[i]),
table.GetVDWRadius(AtomType[i]))
output.GetPointData().SetVectors(Radii)
from fury.utils import numpy_to_vtk_points
Points = np.array(Points)
points = numpy_to_vtk_points(Points)
output.SetPoints(points)
# send the polydata to the filter
ribbonFilter = vtk.vtkProteinRibbonFilter()
ribbonFilter.SetInputData(output)