cmd.select('arg1', 'name nh1 and resn arg within %s of (name od1 and resn asp)'%(7))
cmd.select('arg2', 'name nh2 and resn arg within %s of (name od2 and resn asp)'%(7))
cmd.select('arg3', 'name ne and resn arg within %s of (name cb and resn asp)'%(6.5))
cmd.select('arg4', 'name nh2 and resn arg within %s of (name ca and resn cys)'%(7))
cmd.select('arg5', 'name nh1 and resn arg within %s of (name cb and resn cys)'%(7))
cmd.select('arg6', 'name ne and resn arg within %s of (name sg and resn cys)'%(6.5))
cmd.select('arg7', 'name nh2 and resn arg within %s of (name og and resn ser)'%(10))
cmd.select('arg8', 'name nh1 and resn arg within %s of (name cb and resn ser)'%(11.2))
cmd.select('arg9', 'name ne and resn arg within %s of (name ca and resn ser)'%(9))
cmd.select('arg', 'byres arg1 and byres arg2 and byres arg3 and byres arg4 and byres arg5 and byres arg6 and byres arg6 and byres arg7 and byres arg8 and byres arg9')
cmd.select('asp1', 'name od1 and resn asp within %s of (name nh1 and arg)'%(7))
cmd.select('asp2', 'name od2 and resn asp within %s of (name nh2 and arg)'%(7))
cmd.select('asp3', 'name cb and resn asp within %s of (name ne and arg)'%(6.5))
cmd.select('asp4', 'name od2 and resn asp within %s of (name c and resn ser)'%(11))
cmd.select('asp5', 'name od1 and resn asp within %s of (name ca and resn ser)'%(12))
cmd.select('asp6', 'name cb and resn asp within %s of (name cb and resn ser)'%(9.2))
cmd.select('asp7', 'name od1 and resn asp within %s of (name c and resn cys)'%(12))
cmd.select('asp8', 'name od2 and resn asp within %s of (name cb and resn cys)'%(11))
cmd.select('asp9', 'name cb and resn asp within %s of (name sg and resn cys)'%(10))
cmd.select('asp', 'byres asp1 and byres asp2 and byres asp3 and byres asp4 and byres asp5 and byres asp6 and byres asp7 and byres asp8 and byres asp9')
cmd.select('cys1', 'name ca and resn cys within %s of (name og and resn ser)'%(6.5))
cmd.select('cys2', 'name cb and resn cys within %s of (name cb and resn ser)'%(7))
cmd.select('cys3', 'name sg and resn cys within %s of (name ca and resn ser)'%(6))
cmd.select('cys4', 'name c and resn cys within %s of (name od1 and asp)'%(12))
cmd.select('cys5', 'name cb and resn cys within %s of (name od2 and asp)'%(11))
cmd.select('cys6', 'name sg and resn cys within %s of (name cb and asp)'%(10))
cmd.select('cys7', 'name ca and resn cys within %s of (name nh2 and arg)'%(7))
cmd.select('cys8', 'name cb and resn cys within %s of (name nh1 and arg)'%(7))
cmd.select('cys9', 'name sg and resn cys within %s of (name ne and arg)'%(6.5))
cmd.select('cys', 'byres cys1 and byres cys2 and byres cys3 and byres cys4 and byres cys5 and byres cys6 and byres cys7 and byres cys8 and byres cys9')
cmd.select('ser1', 'name og and resn ser within %s of (name nh2 and arg)'%(10))
cmd.select('ser2', 'name cb and resn ser within %s of (name nh1 and arg)'%(11.2))
cmd.select('ser3', 'name ca and resn ser within %s of (name ne and arg)'%(9))
cmd.select('ser4', 'name c and resn ser within %s of (name od2 and asp)'%(11))
cmd.select('ser5', 'name ca and resn ser within %s of (name od1 and asp)'%(12))
cmd.select('ser6', 'name cb and resn ser within %s of (name cb and asp)'%(9.2))
cmd.select('ser7', 'name og and resn ser within %s of (name ca and cys)'%(6.5))
cmd.select('ser8', 'name cb and resn ser within %s of (name cb and cys)'%(7))
cmd.select('ser9', 'name ca and resn ser within %s of (name sg and cys)'%(6))
cmd.select('ser', 'byres ser1 and byres ser2 and byres ser3 and byres ser4 and byres ser5 and byres ser6 and byres ser7 and byres ser8 and byres ser9')      
cmd.select('Motif', 'ser(asp(arg(cys)))')
tycount = cmd.index('Motif')
atcount  = len(tycount)
if(atcount < 1):
    cmd.hide('everything')
    cmd.select('arg1', 'name nh1 and resn arg within %s of (name od1 and resn asp)'%(7))
    cmd.select('arg2', 'name nh2 and resn arg within %s of (name od2 and resn asp)'%(7))
    cmd.select('arg3', 'name ne and resn arg within %s of (name cb and resn asp)'%(6.5))
    cmd.select('arg4', 'name nh2 and resn arg within %s of (name ca and resn cys)'%(7))
    cmd.select('arg5', 'name nh1 and resn arg within %s of (name cb and resn cys)'%(7))
    cmd.select('arg6', 'name ne and resn arg within %s of (name sg and resn cys)'%(6.5))
    cmd.select('arg', 'byres arg1 and byres arg2 and byres arg3 and byres arg4 and byres arg5 and byres arg6 and byres arg6')
    cmd.select('asp1', 'name od1 and resn asp within %s of (name nh1 and resn arg)'%(7))
    cmd.select('asp2', 'name od2 and resn asp within %s of (name nh2 and resn arg)'%(7))
    cmd.select('asp3', 'name cb and resn asp within %s of (name ne and resn arg)'%(6.5))
    cmd.select('asp7', 'name od1 and resn asp within %s of (name c and resn cys)'%(12))
    cmd.select('asp8', 'name od2 and resn asp within %s of (name cb and resn cys)'%(11))
    cmd.select('asp9', 'name cb and resn asp within %s of (name sg and resn cys)'%(10))
    cmd.select('asp', 'byres asp1 and byres asp2 and byres asp3 and byres asp7 and byres asp8 and byres asp9')
    cmd.select('cys4', 'name c and resn cys within %s of (name od1 and resn asp)'%(12))
    cmd.select('cys5', 'name cb and resn cys within %s of (name od2 and resn asp)'%(11))
    cmd.select('cys6', 'name sg and resn cys within %s of (name cb and resn asp)'%(10))
    cmd.select('cys7', 'name ca and resn cys within %s of (name nh2 and resn arg)'%(7))
    cmd.select('cys8', 'name cb and resn cys within %s of (name nh1 and resn arg)'%(7))
    cmd.select('cys9', 'name sg and resn cys within %s of (name ne and resn arg)'%(6.5))
    cmd.select('cys', 'byres cys4 and byres cys5 and byres cys6 and byres cys7 and byres cys8 and byres cys9')
    cmd.select('Motif', '(asp(arg(cys)))')
    cmd.delete('arg')
    cmd.delete('arg1')
    cmd.delete('arg2')
    cmd.delete('arg3')
    cmd.delete('arg4')
    cmd.delete('arg5')
    cmd.delete('arg6')
    cmd.delete('arg7')
    cmd.delete('arg8')
    cmd.delete('arg9')    
    cmd.delete('ser')
    cmd.delete('ser1')
    cmd.delete('ser2')
    cmd.delete('ser3')
    cmd.delete('ser4')
    cmd.delete('ser5')
    cmd.delete('ser6')
    cmd.delete('ser7')
    cmd.delete('ser8')
    cmd.delete('ser9')
    cmd.delete('asp')
    cmd.delete('asp1')
    cmd.delete('asp2')
    cmd.delete('asp3')
    cmd.delete('asp4')
    cmd.delete('asp5')
    cmd.delete('asp6')
    cmd.delete('asp7')
    cmd.delete('asp8')
    cmd.delete('asp9') 
    cmd.delete('cys')
    cmd.delete('cys1')
    cmd.delete('cys2')
    cmd.delete('cys3')
    cmd.delete('cys4')
    cmd.delete('cys5')
    cmd.delete('cys6')
    cmd.delete('cys7')
    cmd.delete('cys8')
    cmd.delete('cys9')
cmd.hide("everything","all")
cmd.show("cartoon", "all")
cmd.set("cartoon_transparency","0.5", "all")
cmd.show("sticks","Motif")
cmd.color("grey","all")
cmd.color("oxygen","(elem O and Motif)")
cmd.color("nitrogen","(elem N and Motif)")
cmd.color("sulfur","(elem S and Motif)")
cmd.color("hydrogen","(elem H and Motif)")
cmd.color("white","(elem C and Motif)")
cmd.deselect()
cmd.orient("Motif")

