Calculating genus polynomials via string operations and matrices