Ejemplo n.º 1
0
    def test_get_contig_collection_spades_1(self, spades_1_maxk_17):
        # Function for testing function `src.contigs.get_contig_collection`

        infpath: str = spades_1_maxk_17[0]
        maxk: int = spades_1_maxk_17[1]

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

        # Check length of the collection
        expected_len: int = 7
        assert len(contig_collection) == expected_len

        # Check if all items are of class `src.contigs.Contig`
        assert all(map(lambda x: isinstance(x, cnt.Contig), contig_collection))

        # Check if all `Contig`s' attributes are not None (except `multplty`) and of proper types
        attr_name: str
        get_attr: GetAttrFunc
        attr_type: type
        for attr_name, get_attr, attr_type in self._attribute_generator():
            try:
                # Check if it is not None
                assert all(map(lambda x: not get_attr(x) is None, contig_collection))
                # Check type
                assert all(map(lambda x: isinstance(get_attr(x), attr_type), contig_collection))
            except AttributeError:
                pytest.fail('Error: Contig instance attribute has no `{}` attribute.'\
                    .format(attr_name))
def contig_collection_a5_repeat() -> cnt.ContigCollection:

    mink: int = 15
    maxk: int = 15

    contig_collection: cnt.ContigCollection = cnt.get_contig_collection(
        os.path.join('tests', 'data', 'test_contigs_a5_repeat.fasta'), maxk)

    overlap_collection: ovl.OverlapCollection = ovl.detect_adjacent_contigs(
        contig_collection, mink, maxk)

    return contig_collection, overlap_collection
def contig_collection_spades_1() -> cnt.ContigCollection:

    mink: int = 8
    maxk: int = 17

    contig_collection: cnt.ContigCollection = cnt.get_contig_collection(
        os.path.join('tests', 'data', 'test_contigs_spades_1.fasta.gz'), maxk)

    overlap_collection: ovl.OverlapCollection = ovl.detect_adjacent_contigs(
        contig_collection, mink, maxk)

    return contig_collection, overlap_collection
def contig_collection_spades_no_multplty_0() -> cnt.ContigCollection:

    mink: int = 16
    maxk: int = 25

    contig_collection: cnt.ContigCollection = cnt.get_contig_collection(
        os.path.join('tests', 'data',
                     'test_contigs_spades_no_multplty_0.fasta'), maxk)

    overlap_collection: ovl.OverlapCollection = ovl.detect_adjacent_contigs(
        contig_collection, mink, maxk)

    return contig_collection, overlap_collection
Ejemplo n.º 5
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
Ejemplo n.º 6
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)