Created
October 2, 2020 21:08
-
-
Save alisterburt/6fc7381aa7f48b3e1dd32ab6428448bf to your computer and use it in GitHub Desktop.
select classes from relion STAR files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import click | |
import starfile | |
@click.command() | |
@click.option('--star_file', prompt='Input STAR file') | |
@click.option('--class_idx', type=int, prompt='Class number') | |
def class_select(star_file, class_idx): | |
star = starfile.read(star_file) | |
subset = star[star['rlnClassNumber']==class_idx] | |
out_fname = star_file.replace(f'.star', f'_class{class_idx}.star') | |
starfile.write(subset, out_fname) | |
click.echo(f'Before: {star.shape[0]} particles') | |
click.echo(f'After: {subset.shape[0]} particles') | |
return | |
if __name__ == '__main__': | |
class_select() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment