code for processing genetic matrix