コード例 #1
0
def typed(token):
    """Convert single value tokens into a result."""
    trait = Trait(start=token.start, end=token.end)
    trait.notation = token.group["notation"]
    trait.value = to_positive_int(token.group["value1"])
    trait.value += to_positive_int(token.group.get("value2"))
    return trait
コード例 #2
0
def convert_count(token):
    """Convert parsed tokens into a result."""
    trait = Trait(start=token.start, end=token.end)

    value = to_positive_int(token.group.get("value"))
    count1 = to_positive_int(token.group.get("count1"))
    count2 = to_positive_int(token.group.get("count2"))

    if not value:
        value = count1 + count2

    if value >= 1000:
        return None

    trait.value = "present" if value > 0 else "absent"

    return trait
コード例 #3
0
def convert_count(token):
    """Convert parsed tokens into a result."""
    trait = Trait(start=token.start, end=token.end)

    trait.value = to_positive_int(token.group.get("value"))
    count1 = to_positive_int(token.group.get("count1"))
    count2 = to_positive_int(token.group.get("count2"))
    side1 = SUB.get(token.group.get("side1", " ").lower()[0], "side1")
    side2 = SUB.get(token.group.get("side2", " ").lower()[0], "side2")

    if not trait.value:
        trait.value = count1 + count2

    if count1 or side1 != "side1":
        setattr(trait, side1, count1)

    if count2 or side2 != "side2":
        setattr(trait, side2, count2)

    return trait if all(x < 1000 for x in as_list(trait.value)) else None
コード例 #4
0
def each_side(token):
    """Count the found embryo."""
    trait = Trait(start=token.start, end=token.end)

    if token.group.get("subcount"):
        count = to_positive_int(token.group["subcount"])
        trait.value = count + count
        trait.left = count
        trait.right = count

    return trait
コード例 #5
0
def convert(token):
    """Convert parsed tokens into a result."""
    trait = Trait(start=token.start, end=token.end)

    if token.group.get("total"):
        trait.value = to_positive_int(token.group["total"])

    if token.group.get("subcount"):
        trait.value = sum(
            to_positive_int(c) for c in as_list(token.group["subcount"]))

    if token.group.get("subcount") and token.group.get("sub"):
        for count, sub in zip(as_list(token.group["subcount"]),
                              as_list(token.group.get("sub"))):
            count = "1" if count == "!" else count
            sub = SUB.get(sub[0].lower(), sub)
            setattr(trait, sub, to_positive_int(count))

    elif token.group.get("side"):
        side = token.group["side"].lower()
        trait.side = SUB.get(side, side)

    return trait if all(x < 1000 for x in as_list(trait.value)) else None
コード例 #6
0
def convert(token):
    """Convert single value tokens into a result."""
    value = token.group.get("value")

    if not value:
        return None

    trait = Trait(start=token.start, end=token.end)
    trait.value = to_positive_int(value)

    if trait.value > 100:
        return None

    if token.group.get("notation"):
        trait.notation = token.group["notation"]

    return trait