Beispiel #1
0
def screenRecords(
        stream,
        separatorRE,
        idRE=None,
        keep=False,
        screen_set=None,
        screenFile=None):
    """
    uses recordIterator(strean, separatorRE, idRE) to parse input into records
    uses screen_set (can be read from screenFile) to identify records
    identified records are kept or skipped based on the value of keep
    """

    if screen_set is None:
        if screenFile is None:
            raise Exception(
                "Please supply a hash(Python map) or file of record keys")
        else:
            screen_set = parse_list_to_set(screenFile)

    for (
            recordId,
            recordLines) in recordIterator(
            stream,
            separatorRE,
            idRE=idRE):
        screened = recordId in screen_set
        if screened == keep:
            for line in recordLines:
                yield line
def get_group_set(groups, taxonomy):
    """
    Return set of all indicated taxids
    input may be a taxid, taxon name, or file listing taxids
    """
    if groups is None or len(groups) == 0:
        return None
    taxidset = set()
    for group in groups:
        if os.path.isfile(group):
            taxidset.update(parse_list_to_set(group, keyType=int))
        else:
            taxon = getTaxonFromArg(taxonomy, group)
            taxidset.update(create_taxid_set(taxon))

    return taxidset
def get_group_set(groups, taxonomy):
    """
    Return set of all indicated taxids
    input may be a taxid, taxon name, or file listing taxids
    """
    if groups is None or len(groups) == 0:
        return None
    taxidset = set()
    for group in groups:
        if os.path.isfile(group):
            taxidset.update(parse_list_to_set(group, keyType=int))
        else:
            taxon = getTaxonFromArg(taxonomy, group)
            taxidset.update(create_taxid_set(taxon))

    return taxidset