How to use the bamnostic.utils.Roi function in bamnostic

To help you get started, we’ve selected a few bamnostic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github betteridiot / bamnostic / bamnostic / utils.py View on Github external
...
            ValueError: either contig or reference must be set, not both

    """

    # Check synonyms for the reference sequence
    if contig and reference:
        if contig != reference:
            raise ValueError('either contig or reference must be set, not both')
        else:
            contig = contig
    elif contig or reference:
        contig = contig if contig else reference

    # make sure the same thing isn't computed twice
    if type(contig) is Roi:  # class defined in bamnostic.utils
        query = contig

    # check for SAM-formatted regions or bed file format
    elif region or (contig is not None and (':' in contig or '\t' in contig)):
        roi = region if region else contig
        query = _handle_split_region(_parse_sam_region(roi), until_eof=until_eof)
    else:
        if tid and not contig:
            contig = None

        if (stop and end) and (stop != end):
            raise ValueError('either stop or end must be set, not both')
        else:
            stop = stop if stop else end

        query = _handle_split_region((contig, start, stop), until_eof=until_eof)
github betteridiot / bamnostic / bamnostic / utils.py View on Github external
ValueError: if `until_eof` is not set and region is open-ended or improper region format.

    """
    split_roi = list(split_roi)
    # make sure the user didn't put multiple positional arguments
    if 1 <= len(split_roi) <= 3:

        # if the user gives an integer description of chromosome, convert to string
        if isinstance(split_roi[0], (str, int)):
            split_roi[0] = str(split_roi[0])

        if None in split_roi[1:]:
            # make sure the user wants to continue if they have used an open-ended region
            if not until_eof:
                raise ValueError('Open-ended region while `until_eof` is set to False')
        return Roi(*split_roi)
    else:
        raise ValueError('improper region format')