module Bio.PDB.EventParser.ParseCONECT(parseCONECT)
where
import qualified Data.ByteString.Char8 as BS
import Bio.PDB.EventParser.PDBEvents
import Bio.PDB.EventParser.PDBParsingAbstractions
conectFields = [(6, mKeyword "record header" "CONECT"),
(11, mInt "atom serial number" ),
(16, mInt "atom serial number" ),
(21, pInt "atom serial number" ),
(26, pInt "atom serial number" ),
(31, pInt "atom serial number" )]
intList (IFInt i:ls) = i:intList ls
intList (IFNone :ls) = intList ls
intList [] = []
parseCONECT :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
parseCONECT line line_no = return $ if null errs
then [result]
else errs
where
(fields, errs) = parseFields conectFields line line_no
[fRec, fS1, fS2, fS3, fS4, fS5] = fields
serials = intList [fS1, fS2, fS3, fS4, fS5]
result = CONECT { atoms = serials }