-- F.Damberger 11.Nov.2004 -- This not copied to the cara wiki yet -- WARNING: Always backup your Repository before executing this script. -- It erases spinlinks and there is no undo. -- Short Description -- Script to remove all spinlinks within a particular segment of the sequence -- Spinlinks connecting two spins which are both within the sequence fragment -- are removed. All other spinlinks are kept (e.g. a spinlink between one -- spin A within the sequence fragment and another B outside the fragment is -- kept) -- Purpose -- The script is intended to remove spinlinks representing UPLs within a given -- sequence stretch without affecting spinlinks which represent UPLs between -- that sequence stretch and other parts of the sequence. -- Example: You are studying a homodimer consisting of the monomers A and B. -- So you repeat the sequence to represent the second monomer. You also -- duplicate all the spins and spinlinks in the second monomer. -- This way you can represent spinlinks between the two monomers by making -- a spinlink from an atom in monomer A to one in monomer B. -- However, the duplicated spinlinks within monomers A and B result in peaks -- which are degenerate when you export the Strip peaks to MonoScope: The -- integration routine fails when peaks are degenerate. To avoid this, you -- must remove all the duplicated "INTRAmolecular" spinlinks within monomer B. -- (USE THIS SCRIPT TO ACCOMPLISH THE TASK) -- Then you can export the strip peaks to monoscope and integrate. -- After integration, you will have to copy the peaks corresponding to -- INTRAmolecular spinlinks within monomer A to related peaks corresponding to -- INTRAmolecular spinlinks within monomer B. -- This second task can be performed with a second LUA script -- "DuplicatePeaksToSecondMonomer.lua". t = {} -- ---------------------- Main Program ------------------------ -- Get Input from User --1. Get ProjectName local ProjectNames = {} i = 0 for a,b in pairs(cara:getProjects()) do i = i + 1 ProjectNames[ i ] = b:getName() end t.ProjectName=dlg.getSymbol("Select Project","", unpack( ProjectNames ) ) t.P = cara:getProject( t.ProjectName ) --2. Get Sequence Range to remove INTRA spinlinks from t.Seq = t.P:getSequence() t.ResNumStart = dlg.getInteger("Enter the residue number for the start of the sequence fragment","Enter an integer", 1 ) for a,b in pairs( t.Seq ) do if (a == t.ResNumStart) then t.StartExists = true end end if t.StartExists then t.ResNumEnd = dlg.getInteger("Enter the residue number for the end of the sequence fragment","Enter an integer", 1 ) for a,b in pairs( t.Seq ) do if (a == t.ResNumEnd) then t.EndExists = true end end if t.EndExists and t.ResNumEnd >= t.ResNumStart then -- Search for SpinLinks linking spins within this sequence fragment print("Deleted to following Spinlinks: SpinID ResID SpinID ResId") t.SpinLinks = t.P:getSpinLinks() for SpinLinkId,SpinLink in pairs(t.SpinLinks) do -- is it a spinlink between atoms within the range of residues selected? -- Get the left and right residue from the spinlink t.LeftSpin = t.P:getSpin(SpinLink:getLeft()) t.RightSpin = t.P:getSpin(SpinLink:getRight()) if t.LeftSpin:getSystem() then t.LeftSys = t.LeftSpin:getSystem() end if t.RightSpin:getSystem() then t.RightSys = t.RightSpin:getSystem() end if t.LeftSys:getResidue() then t.LeftRes = t.LeftSys:getResidue() end if t.RightSys:getResidue() then t.RightRes = t.RightSys:getResidue() end -- check whether both spins are in a residue if t.LeftRes and t.RightRes then -- print( t.LeftSpin:getId().." "..t.LeftRes:getId().." "..t.RightSpin:getId().." "..t.RightRes:getId() ) -- check whether left and right residues are in the fragment t.Res = t.P:getResidue( t.ResNumStart ) t.LeftResInFragment = nil t.RightResInFragment = nil -- iterate through all residues in the fragment while t.Res:getId() ~= t.ResNumEnd do -- print("t.Res="..t.Res:getId().." t.ResNumEnd="..t.ResNumEnd.." t.LeftRes="..t.LeftRes:getId().." t.RightRes="..t.RightRes:getId()) if t.Res:getId() == t.LeftRes:getId() then t.LeftResInFragment = true -- print("t.LeftResInFragment") elseif t.Res:getId() == t.RightRes:getId() then t.RightResInFragment = true -- print("t.RightResInFragment = true") else end t.Res = t.Res:getSucc() -- next residue end -- now handle the last residue in the fragment if t.Res:getId() == t.ResNumEnd then -- print("t.Res="..t.Res:getId().." t.ResNumEnd="..t.ResNumEnd.." t.LeftRes="..t.LeftRes:getId().." t.RightRes="..t.RightRes:getId()) if t.Res:getId() == t.LeftRes:getId() then t.LeftResInFragment = true end if t.Res:getId() == t.RightRes:getId() then t.RightResInFragment = true end end -- if LeftSpin and RightSpin are in fragment, then delete link between them if t.LeftResInFragment == true and t.RightResInFragment == true then print("deleting the spinlink: "..t.LeftSpin:getId().." "..t.LeftRes:getId().." "..t.RightSpin:getId().." "..t.RightRes:getId()) t.P:unlinkSpins( t.LeftSpin, t.RightSpin ) end end end else print("Either The Start Residue Number") print("is greater than the End Residue Number") print("or the End Residue Does not exist,") print("please check sequence and try again") t.ErrorMessage = "ERROR: see Text Window" end else print("This residue number does not exist,") print("please check sequence and try again") t.ErrorMessage = "ERROR: see Text Window" end if t.ErrorMessage then print(t.ErrorMessage) else print("DeleteSpinLinksWithinSequenceFragment.lua is finished") end t = nil