module Bio.PDB.EventParser.ParseSHEET(parseSHEET)
where
import Prelude hiding(String)
import qualified Data.ByteString.Char8 as BS
import Bio.PDB.EventParser.StrandSense
import Bio.PDB.EventParser.PDBEvents
import Bio.PDB.EventParser.PDBParsingAbstractions
helixFields = [(6, mKeyword "record header" "SHEET " ),
(7, mSpc 1 ),
(10, mInt "strand" ),
(11, mSpc 1 ),
(14, mStr "sheet id" ),
(16, mInt "number of strands" ),
(17, mSpc 1 ),
(20, mStr "initial residue name" ),
(21, mSpc 1 ),
(22, mChr "initial residue chain id" ),
(26, mInt "initial residue serial number" ),
(27, mChr "initial insertion code" ),
(28, mSpc 1 ),
(31, mStr "end residue name" ),
(32, mSpc 1 ),
(33, mChr "end residue chain id" ),
(37, mInt "end residue serial number" ),
(38, mChr "end insertion code" ),
(40, mInt "sense with respect to previous strand" ),
(41, pSpc ),
(45, pStr "current atom name" ),
(48, pStr "current residue name" ),
(49, pSpc ),
(50, pChr "current chain id" ),
(54, pInt "current residue serial number" ),
(55, pChr "current residue insertion code" ),
(56, pSpc ),
(60, pStr "atom name in previous strand" ),
(63, pStr "residue name in previous strand" ),
(64, pSpc ),
(65, pChr "chain id in previous strand" ),
(69, pInt "residue serial number in previous strand"),
(70, pChr "insertion code in previous strand" )]
parseSHEET :: (Monad m) => String -> Int -> m [PDBEvent]
parseSHEET line line_no =
return $ if errs == []
then [result]
else errs
where
(fields, fErrs) = parseFields helixFields line line_no
[fRec, _, fStrandId, _, fSheetId, fNumStrands, _,
fIniResName, _, fIniChain, fIniResId, fIniResIns, _,
fEndResName, _, fEndChain, fEndResId, fEndResIns,
fSense, _,
fCurAtomName, fCurResName, _, fCurChain, fCurResId, fCurResIns, _,
fPrevAtomName, fPrevResName, _, fPrevChain, fPrevResId, fPrevResIns] = fields
IFInt strandId = fStrandId
IFStr sheetId = fSheetId
IFInt numStrands = fNumStrands
IFStr iniResName = fIniResName
IFChar iniChain = fIniChain
IFInt iniResId = fIniResId
IFChar iniResIns = fIniResIns
fgIniRes = fgResidue False "initial" 20 fIniResName fIniChain fIniResId fIniResIns
Right iniRes = fgIniRes
IFStr endResName = fEndResName
IFChar endChain = fEndChain
IFInt endResId = fEndResId
IFChar endResIns = fEndResIns
fgEndRes = fgResidue False "end" 31 fEndResName fEndChain fEndResId fEndResIns
Right endRes = fgEndRes
IFInt iSense = fSense
sense = case iSense of
( 0) -> Nothing
( 1) -> Just Parallel
(1) -> Just Antiparallel
fgCurAtom = maybeFgAtom "current" 45 fCurAtomName fCurResName fCurChain fCurResId fCurResIns
fgPrevAtom = maybeFgAtom "previous" 60 fPrevAtomName fPrevResName fPrevChain fPrevResId fPrevResIns
fgErrs = liftFgErrs line_no [fgCurAtom, fgPrevAtom] ++
liftFgErrs line_no [fgIniRes, fgEndRes ]
Right curAtom = fgCurAtom
Right prevAtom = fgPrevAtom
errs = fErrs ++ fgErrs
result = SHEET strandId sheetId numStrands sense
iniRes
endRes
curAtom
prevAtom