Since the above solution comes with a lot of fiddeling and might be too tideous for a huge number of samples you could alternatively use pythons pandas module and all its cool filtering and selection capabilities. Load the biom table into a pandas DataFrame, manipulate the data as you need and write it back to a new biom table. If you are firm in python, that might be the easier way.