def test_assign_multiplty_spades_0(self, contig_collection_spades_0):
        # Test how the function assigns multiplicity to contigs from
        #   file `test_contigs_spades_0.fasta

        # "Rename" variable
        contig_collection: cnt.ContigCollection
        overlap_collection: ovl.OverlapCollection
        contig_collection, overlap_collection = contig_collection_spades_0

        # Assign
        amu.assign_multiplty(contig_collection, overlap_collection)

        expected_multplts: Sequence[float] = tuple([
            1.0,  # NODE_1
            1.0,  # NODE_2
            1.8,  # NODE_3
            1.2  # NODE_4
        ])

        obtained_multplts: Sequence[float] = tuple(
            map(lambda x: x.multplty, contig_collection))

        # Compare lengths
        assert len(obtained_multplts) == len(expected_multplts)

        # Compare multiplicities
        for expected, obtained in zip(expected_multplts, obtained_multplts):
            assert abs(obtained - expected) < 1e-1
Пример #2
0
def _do_combinator_work(infpath: str, mink: int,
                        maxk: int) -> MockContigsFixture:

    # Read contigs
    contig_collection: cnt.ContigCollection = cnt.get_contig_collection(
        infpath, maxk)

    # Detect adjacent contigs
    overlap_collection: ovl.OverlapCollection = ovl.detect_adjacent_contigs(
        contig_collection, mink, maxk)

    # Assign multiplicity to contigs
    amu.assign_multiplty(contig_collection, overlap_collection)

    return contig_collection, overlap_collection
Пример #3
0
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)