예제 #1
0
def DummyNeighbors(allProts, path, stpFile, dnFile, neighborType):
    prizes = set()
    with open(os.path.join(path, stpFile)) as f:
        for line in f:
            parts = line.split()
            # mRNAs can't be Steiner nodes
            if parts[0] == "W" and not parts[1].endswith("_MRNA"):
                prizes.add(parts[1])

    psNodes = allProts.difference(prizes)

    if neighborType == "prizes":
        NetworkUtil.WriteCollection(os.path.join(path, dnFile), prizes)
    elif neighborType == "nonprizes":
        NetworkUtil.WriteCollection(os.path.join(path, dnFile), psNodes)
    else:
        raise RuntimeError(
            "%s is not a valid type of dummy node neighbor connection" %
            neighborType)

    return psNodes