Esempio n. 1
0
def ingame_menu():
    """The menu that appears after the main menu/the first menu"""
    # While loop for continous play
    while True:
        # Tells user that typing q goes to the main menu
        print('type q to go back to the main menu')
        # Asks for user input
        menu = input('type map/inventory/characters: ')
        # Makes all the user input into lower case
        menu = menu.lower()
        # Checks to see if user typed inventory
        if menu == 'inventory':
            # Tells user to type in certain commands to access further menus
            print('type [weapon], [fishing rod], [heal]')
            # Runs the inventory function
            inv.inventory()
        # Checks to see if user typed location
        elif menu == 'map':
            # Runs the location function
            loc.location()
        elif menu == 'characters':
            ch.all_characters()
        # Checks to see if user typed in q
        elif menu == 'q':
            # Goes to main menu
            break
        # Checks to see if anything else was typed in
        else:
            # Tells user that was an invalid selection
            print('invalid select again')
Esempio n. 2
0
def translocation(chr1, pos1, chr2, pos2, ct):
    secondStrand = "+"
    firstExtendRight = False
    secondExtendRight = True
    if ct is None or ct == '3to5':
        pass
    elif ct == '5to3':
        firstExtendRight = True; secondExtendRight = False
    elif ct == '5to5':
        firstExtendRight = True; secondExtendRight = True; secondStrand = '-'
    elif ct == '3to3':
        firstExtendRight =False; secondExtendRight =False; secondStrand = '-'

    return ( loc.location(chr1, pos1, "+",          firstExtendRight), 
             loc.location(chr2, pos2, secondStrand, secondExtendRight) )
Esempio n. 3
0
def translocation(chr1, pos1, chr2, pos2, ct):
    secondStrand = "+"
    firstExtendRight = False
    secondExtendRight = True
    if ct is None or ct == '3to5':
        pass
    elif ct == '5to3':
        firstExtendRight = True
        secondExtendRight = False
    elif ct == '5to5':
        firstExtendRight = True
        secondExtendRight = True
        secondStrand = '-'
    elif ct == '3to3':
        firstExtendRight = False
        secondExtendRight = False
        secondStrand = '-'

    return (loc.location(chr1, pos1, "+", firstExtendRight),
            loc.location(chr2, pos2, secondStrand, secondExtendRight))
Esempio n. 4
0
def breakpointsFromRecord(record):
    """Returns a list of pair(s) of breakpoints corresponding to the record."""
    global __symbolicRE__
    global __bpRE__
    global __looseendRE__

    chr1, pos1 = stdchrom(record.CHROM), int(record.POS)
    first = loc.location(chr1, pos1)

    if record.ALT is None:
        return [(first, loc.location(None, 0, "+", True))]

    setupREs()
    ref = str(record.REF)
    bkptPairs = []

    for alt in record.ALT:
        if alt is None:
            altstr = "."
        else:
            altstr = str(alt)

        # get all available information from the record
        chr2, pos2, ct, svtype, svlen = otherPosnSymbolic(record.INFO)

        # defaults
        if chr2 is None:
            chr2 = chr1

        # look for symbolic SVTYPE information in the alt field (eg, <DEL>)
        resultSym = re.match(__symbolicRE__, altstr)
        if resultSym:
            svtype = resultSym.group(1)

        # explicit BP - look for chr2 and CT information from the alt field
        # (eg, N[chr2:123123[)
        resultBP = re.match(__bpRE__, altstr)
        if resultBP:
            ct, chr2, pos2, indellen = ctAndLocFromBkpt(
                str(record.REF), resultBP.group(1), resultBP.group(2),
                resultBP.group(3), resultBP.group(4), resultBP.group(5))
            if svlen is None:
                svlen = indellen

        # looseend; no paired BP
        resultLE = __looseendRE__.search(str(record.FILTER))
        if altstr == ref + "." or resultLE:
            chr2 = None
            pos2 = 0
            if ct is None:
                ct = '5to3'
        if altstr == "." + ref:
            chr2 = None
            pos2 = 0
            if ct is None:
                ct = '3to5'

        # if nothing else, treat as an indel
        if not svtype and not resultBP and not resultLE and not resultSym:
            reflen = len(ref)
            if pos2 is None:
                pos2 = pos1 + reflen
            if svlen is None:
                svlen = len(altstr) - reflen
            if svtype is None:
                if svlen > 0:
                    svtype = 'INS'
                else:
                    svtype = 'DEL'

        if svtype == "INV":
            assert chr1 == chr2
            bkptPairs.append(translocation(chr1, pos1, chr1, pos2 - 1, '3to3'))
            bkptPairs.append(translocation(chr1, pos1 + 1, chr1, pos2, '5to5'))
        elif svtype in ["DUP:TANDEM", "DUP"]:
            if chr2 is None:
                chr2 = chr1
            if ct is None or ct == "5to3" or ct == "3to5":
                if pos1 > pos2:
                    pos1, pos2 = pos2, pos1
                bkptPairs.append(translocation(chr1, pos1, chr2, pos2, "5to3"))
            else:
                bkptPairs.append(translocation(chr1, pos1, chr2, pos2, ct))
        elif svtype in ["INS", "INS:ME:L1"]:
            assert chr1 == chr2
            bkptPairs.append((first, loc.location(chr1, pos1 + 1, "+", True)))
        elif svtype in ["DEL:ME:ALU", "DEL"]:
            assert chr1 == chr2
            bkptPairs.append(
                translocation(chr1, min(pos1, pos2), chr1, max(pos1, pos2),
                              '3to5'))
        else:
            # translocation is the default
            if ct is None:
                ct = "3to5"
            if (svtype is not None) and (not svtype in ["TRA", "BND"]):
                print("Got unknown record of type",
                      svtype,
                      altstr,
                      str(record),
                      file=sys.stderr)
                print("Hoping for best", file=sys.stderr)
            bkptPairs.append(translocation(chr1, pos1, chr2, pos2, ct))

    orderedPairs = [orderBreakpoints(bp1, bp2) for bp1, bp2 in bkptPairs]
    return orderedPairs
Esempio n. 5
0
def breakpointsFromRecord(record):
    """Returns a list of pair(s) of breakpoints corresponding to the record."""
    global __symbolicRE__
    global __bpRE__
    global __looseendRE__

    chr1, pos1 = stdchrom(record.CHROM), int(record.POS)
    first = loc.location(chr1, pos1)

    if record.ALT is None:
        return [(first, loc.location(None,0,"+",True))]

    setupREs()
    ref = str(record.REF)
    bkptPairs = []

    for alt in record.ALT:
        if alt is None:
            altstr = "."
        else:
            altstr = str(alt)

        # get all available information from the record 
        chr2, pos2, ct, svtype, svlen = otherPosnSymbolic(record.INFO)

        # defaults
        if chr2 is None:
            chr2 = chr1

        # look for symbolic SVTYPE information in the alt field (eg, <DEL>)
        resultSym = re.match(__symbolicRE__, altstr)
        if resultSym:
            svtype = resultSym.group(1)

        # explicit BP - look for chr2 and CT information from the alt field 
        # (eg, N[chr2:123123[)
        resultBP = re.match(__bpRE__, altstr)
        if resultBP:
            ct, chr2, pos2, indellen = ctAndLocFromBkpt(str(record.REF), resultBP.group(1),
                    resultBP.group(2), resultBP.group(3), resultBP.group(4),
                    resultBP.group(5))
            if svlen is None:
                svlen = indellen

        # looseend; no paired BP
        resultLE = __looseendRE__.search(str(record.FILTER))
        if altstr == ref+"." or resultLE:
            chr2 = None; pos2 = 0
            if ct is None:
                ct = '5to3'
        if altstr == "."+ref:
            chr2 = None; pos2 = 0
            if ct is None:
                ct = '3to5'

        # if nothing else, treat as an indel 
        if not svtype and not resultBP and not resultLE and not resultSym:
            reflen = len(ref)  
            if pos2 is None:
                pos2 = pos1 + reflen
            if svlen is None:
                svlen = len(altstr) - reflen
            if svtype is None:
                if svlen > 0:
                    svtype = 'INS'
                else:
                    svtype = 'DEL'
        
        if svtype == "INV":
            assert chr1 == chr2
            bkptPairs.append( translocation(chr1, pos1,   chr1, pos2-1, '3to3') )
            bkptPairs.append( translocation(chr1, pos1+1, chr1, pos2,   '5to5') )
        elif svtype in ["DUP:TANDEM","DUP"]:
            if chr2 is None:
                chr2 = chr1
            if ct is None or ct=="5to3" or ct=="3to5":
                if pos1 > pos2:
                    pos1, pos2 = pos2, pos1
                bkptPairs.append( translocation(chr1, pos1, chr2, pos2, "5to3") )
            else:
                bkptPairs.append( translocation(chr1, pos1, chr2, pos2, ct) )
        elif svtype in ["INS","INS:ME:L1"]:
            assert chr1 == chr2
            bkptPairs.append((first, loc.location(chr1, pos1+1, "+", True)))
        elif svtype in ["DEL:ME:ALU","DEL"]:
            assert chr1 == chr2
            bkptPairs.append( translocation(chr1, min(pos1,pos2), chr1, max(pos1,pos2), '3to5') )
        else:
            # translocation is the default
            if ct is None:
                ct = "3to5"
            if (svtype is not None) and (not svtype in ["TRA","BND"]):
                print("Got unknown record of type", svtype, altstr, str(record), file=sys.stderr)
                print("Hoping for best",file=sys.stderr)
            bkptPairs.append( translocation(chr1, pos1, chr2, pos2, ct) )

    orderedPairs = [orderBreakpoints(bp1,bp2) for bp1,bp2 in bkptPairs]
    return orderedPairs