Package: pycov3
pycov3A package for generating cov3 files which are generated from sam files giving coverage information and a fasta file giving binned contigs. Cov3 files are used as input for theDEMIC R packagewhich calculates PTR, an estimate for bacterial growth rates.InstallationPyPipipinstallpycov3
pycov3-hBiocondacondacreate-npycov3-cconda-forge-cbiocondapycov3
condaactivatepycov3
pycov3-hDockerHubdockerpullctbushman/pycov3:latest
dockerrun--rm--namepycov3pycov3pycov3-hGitHubgitclonehttps://github.com/Ulthran/pycov3.gitcdpycov3/
pipinstall.
pycov3-hUsageUse-hto see options for running the CLI.$pycov3-hThe FASTAs should all be in one directory with names of the format{sample}.{bin_name}.fasta/.fa/.fnaand the SAMs should also all be in one directory with names of the format{sample}_{bin_name}.sam. The output COV3 files will be written to a directory with names of the format{sample}.{bin_name}.cov3.You can also use the library in your own code. Create a SAM directory and FASTA directory, set any non-default window or coverage parameters, then create a COV3 directory and use it to generate a COV3 file for each contig set in the FASTA directory.frompycov3.DirectoryimportCov3Dir,FastaDir,SamDirsam_d=SamDir(Path("/path/to/sams/"),False)window_params={"window_size":None,"window_step":None,"edge_length":sam_d.calculate_edge_length(),}coverage_params={"mapq_cutoff":None,"mapl_cutoff":None,"max_mismatch_ratio":None,}window_params={k:vfork,vinwindow_params.items()ifvisnotNone}coverage_params={k:vfork,vincoverage_params.items()ifvisnotNone}fasta_d=FastaDir(Path("/path/to/fastas/"),False)cov3_d=Cov3Dir(Path(args.out_dir),False,fasta_d.get_filenames(),window_params,coverage_params,)cov3_d.generate(sam_d,fasta_d)Alternatively, to use the bare application logic and do all the file handling yourself, you can use theCov3Generatorclass which takes a list of generators as SAM inputs and a generator as a FASTA input.frompycov3.Cov3GeneratorimportCov3Generatorfrompycov3.FileimportCov3Filecov3_generator=Cov3Generator(sam_generators,fasta_generator,sample,bin_name,window_params,**coverage_params,)cov3_dict=cov3_generator.generate_cov3()# Write outputcov3_file=Cov3File(Path(/path/to/output/),"001")cov3_file.write_generator(cov3_generator.generate_cov3())Resource RequirementsThreads: pycov3 usesmultiprocessingto parallelize processing of input fastas. Increasing--thread_numup to the number of input fastas should improve runtime, with no benefits beyond that number.Memory: pycov3 uses generators as much as possible. The main memory users are theContigobjects, which each hold a contig's sequence and information for eachWindowover its length. There is also acoveragesdictionary that could potentially grow to the size of the largest contig (but that is very unlikely). At a minimum, twice the size of the largest contig should be given per thread.Algorithmic Complexity: Assuming enough threads are provided to have each fasta file processed separately, the time complexity is roughlyO(cwsr).c: Number of contigs in fastas: Number of sam filesw: Max number of windows per contigr: Max number of records per sam fileHelpPlease use theIssueson this repo for any problems, questions, or suggestions.