Example of reading an MMTF Hadoop Sequence file, filtering the entries by resolution, and counting the number of entries. This example shows how methods can be chained together.
In [2]:
from pyspark import SparkConf, SparkContext
from mmtfPyspark.io import mmtfReader
from mmtfPyspark.filters import RFree
from mmtfPyspark.structureViewer import view_structure
In [3]:
conf = SparkConf().setMaster("local[*]") \
.setAppName("FilterByRFreeDate")
sc = SparkContext(conf = conf)
In [4]:
path = "../../resources/mmtf_reduced_sample/"
structures = mmtfReader.read_sequence_file(path, sc) \
.filter(RFree(0.15,0.25))
print(f"Number of structures : {structures.count()}")
Number of structures : 1397
In [6]:
structure_names = structures.keys().collect()
view_structure(structure_names, style='stick')
Out[6]:
<function mmtfPyspark.structureViewer.view_structure.<locals>.view3d>
In [7]:
sc.stop()