def outdir_two_files_gap(tmpdir_factory, fpath_fasta) -> str: # Output directory with following files: # `file_combinator_adjacent_contigs.tsv` # `file.2_combinator_adjacent_contigs.tsv` outdpath: str = tmpdir_factory.mktemp('outdir-three-files') fls.make_outdir(outdpath) # Configure path to origin output file origin_fpath: str = os.path.join( outdpath, '{}_combinator_adjacent_contigs.tsv'.format( fls.conf_prefix(fpath_fasta, outdpath))) # Create origin output file with open(origin_fpath, 'w') as tmpfile: pass # end with # Create numbered (numbers 1, 2) files i: int for i in range(2): with open( os.path.join( outdpath, '{}_combinator_adjacent_contigs.tsv'.format( fls.conf_prefix(fpath_fasta, outdpath))), 'w') as tmpfile: pass # end with # end for # And remove file number 1 os.unlink(os.path.join(outdpath, 'file.1_combinator_adjacent_contigs.tsv')) return outdpath
def outdir_single_numbered(tmpdir_factory, fpath_fasta) -> str: # Output directory with following files: # `file.1_combinator_adjacent_contigs.tsv` outdpath: str = tmpdir_factory.mktemp('outdir-two-files') fls.make_outdir(outdpath) # Configure path to origin output file origin_fpath: str = os.path.join( outdpath, '{}_combinator_adjacent_contigs.tsv'.format( fls.conf_prefix(fpath_fasta, outdpath))) # Create origin output file with open(origin_fpath, 'w') as tmpfile: pass # end with # Create numbered (number 1) file with open( os.path.join( outdpath, '{}_combinator_adjacent_contigs.tsv'.format( fls.conf_prefix(fpath_fasta, outdpath))), 'w') as tmpfile: pass # end with # And remove origin file os.unlink(origin_fpath) return outdpath
def outdir_single_file(tmpdir_factory, fpath_fasta) -> str: # Output directory with single `file__combinator_adjacent_contigs.tsv` file outdpath: str = tmpdir_factory.mktemp('outdir-single-file') fls.make_outdir(outdpath) # Configure path to origin output file origin_fpath: str = os.path.join( outdpath, '{}_combinator_adjacent_contigs.tsv'.format( fls.conf_prefix(fpath_fasta, outdpath))) # Create origin output file with open(origin_fpath, 'w') as tmpfile: pass # end with return outdpath
def test_make_outdir(self, tmpdir: str): # Should successfully make a directory in `tempdir` # and create a file in it. outdpath: str = os.path.join(tmpdir, 'outdir') fls.make_outdir(outdpath) assert os.path.isdir(outdpath) tesf_fpath = os.path.join(outdpath, 'test.file.txt') with open(tesf_fpath, 'w') as testfile: pass # end with assert os.path.isfile(tesf_fpath)
def main(version: str, last_update_date: str) -> None: contigs_fpaths: Sequence[str] # paths to input files params: Dict[str, Any] # parameters of the program # Parse command line arguments contigs_fpaths, params = parse_args(version, last_update_date) # Report parameters of current run _report_parameters(params, version, last_update_date) # Iterate over input files and process them fpath: str for fpath in contigs_fpaths: print('Processing file `{}`'.format(fpath)) # Create output dir make_outdir(params['o']) # Read contigs contig_collection: cnt.ContigCollection = cnt.get_contig_collection( fpath, params['a']) # Detect adjacent contigs overlap_collection: ovl.OverlapCollection = ovl.detect_adjacent_contigs( contig_collection, params['i'], params['a']) # Assign multiplicity to contigs amu.assign_multiplty(contig_collection, overlap_collection) # Make prefix for current input file prefix: str = conf_prefix(fpath, params['o']) # Write output files # Write adjacency table out.write_adjacency_table(contig_collection, overlap_collection, params['o'], prefix) # Write full log out.write_full_log(contig_collection, overlap_collection, params['o'], prefix) # Write summary out.write_summary(contig_collection, overlap_collection, fpath, params['o'], prefix) print('-' * 20)
def empty_outdir(tmpdir_factory) -> str: # Empty output directory outdpath: str = tmpdir_factory.mktemp('empty-outdir') fls.make_outdir(outdpath) return outdpath