# vtkProteinRibbonFilter usage without using vtkPDBReader

**URL:** https://discourse.vtk.org/t/vtkproteinribbonfilter-usage-without-using-vtkpdbreader/6079
**Category:** Support
**Created:** [June 25, 2021, 6:02pm UTC](https://discourse.vtk.org/t/vtkproteinribbonfilter-usage-without-using-vtkpdbreader/6079 "2021-06-25T18:02:54Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![SunTzunami](https://discourse.vtk.org/user_avatar/discourse.vtk.org/suntzunami/32/3549_2.png) [@SunTzunami](https://discourse.vtk.org/u/SunTzunami)
#### Post date: [July 14, 2021, 5:42am UTC](https://discourse.vtk.org/t/vtkproteinribbonfilter-usage-without-using-vtkpdbreader/6079/2 "2021-07-14T05:42:26Z")

</div>

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](https://discourse.vtk.org/t/proteinribbonfilter/4545/2).  
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) -

```auto
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)

```

---

_[View the full topic](https://discourse.vtk.org/t/vtkproteinribbonfilter-usage-without-using-vtkpdbreader/6079)._
