Example of reading an MMTF Hadoop Sequence file, filtering the entires by resolution, and counting the number of entires.
Understand PDB data resolution
In [1]:
from pyspark import SparkConf, SparkContext
from mmtfPyspark.io import mmtfReader
from mmtfPyspark.filters import Resolution
from mmtfPyspark.structureViewer import view_structure
In [2]:
conf = SparkConf().setMaster("local[*]") \
.setAppName("FilterByResolution")
sc = SparkContext(conf = conf)
In [3]:
path = "../../resources/mmtf_reduced_sample/"
pdb = mmtfReader.read_sequence_file(path, sc)
Entires without resolution values (eg. NMR structures) will be filtered out
In [4]:
pdb = pdb.filter(Resolution(0.0,2.0))
In [5]:
count = pdb.count()
print(f"Number of structures : {count}")
Number of structures : 1959
In [6]:
structure_names = pdb.keys().collect()
view_structure(structure_names)
Out[6]:
<function mmtfPyspark.structureViewer.view_structure.<locals>.view3d>
In [7]:
sc.stop()