original_docstring: Parse parts of the PDB header.
docstring: Parse parts of the PDB header.
docstring_tokens: Parse parts of the PDB header .
code: def parse_header(header):
      """Parse parts of the PDB header."""
      id = (compile('HEADER\s{4}\S+.*\S+\s*\S{9}\s+(\S{4})\s*$'), 'id')
      dt = (compile('HEADER\s{4}\S+.*\S+\s+(\S{9})\s+\S{4}\s*$'), 'date')
      nm = (compile('HEADER\s{4}(\S+.*\S+)\s+\S{9}\s+\S{4}\s*$'), 'name')
      mc = (compile('REMARK 280\s+MATTHEWS COEFFICIENT,\s+VM\s+\(ANGSTROMS\*\*3/DA\):\s+(\d+\.\d+)'), 'matthews')
      sc = (compile('REMARK 280\s+SOLVENT CONTENT,\s+VS\s+\(%\):\s+(\d+\.\d+)'), 'solvent_content')
      sg = (compile('REMARK 290\s+SYMMETRY OPERATORS FOR SPACE GROUP:\s+(.*\S)'), 'space_group')
      xt = (compile('REMARK 200\s+EXPERIMENT TYPE\s+:\s+(.*\S)'), 'experiment_type')
      rs = (compile('REMARK   2\s+RESOLUTION\.\s+(\d+\.\d+)\s+ANGSTROMS\.'), 'resolution')
      rf = (compile('REMARK   3\s+FREE R VALUE\s+:\s+(\d+\.\d+)'), 'r_free')
      xd = (compile('EXPDTA\s+([\w\-]+).*'), 'expdta')
      c1 = (compile('CRYST1\s+((\d+\.\d+\s+){6})'), 'cryst1')
      ra = (compile('DBREF\s+\S{4}\s+\S\s+\d+\s+\d+\s+\S+\s+(\S+)\s+\S+\s+\d+\s+\d+\s+$'), 'dbref_acc')
      rx = (compile('DBREF\s+\S{4}\s+\S\s+\d+\s+\d+\s+\S+\s+\S+\s+(\S+)\s+\d+\s+\d+\s+$'), 'dbref_acc_full')
      #CRYST1   60.456   60.456   82.526  90.00  90.00  90.00 P 41          4
      #DBREF  1UI9 A    1   122  UNP    Q84FH6   Q84FH6_THETH     1    122             \n'
      tests = [id, dt, nm, mc, sc, sg, xt, rs, rf, xd, c1, ra, rx]
      results = {}
      for line in header:
          for (regexp, name) in tests:
              try:
                  results.update({name:regexp.search(line).group(1).strip()})
                  continue # taking only the first grep.
              except AttributeError:
                  pass
      return results
code_tokens: def parse_header ( header ) : id = ( compile ( 'HEADER\s{4}\S+.*\S+\s*\S{9}\s+(\S{4})\s*$' ) , 'id' ) dt = ( compile ( 'HEADER\s{4}\S+.*\S+\s+(\S{9})\s+\S{4}\s*$' ) , 'date' ) nm = ( compile ( 'HEADER\s{4}(\S+.*\S+)\s+\S{9}\s+\S{4}\s*$' ) , 'name' ) mc = ( compile ( 'REMARK 280\s+MATTHEWS COEFFICIENT,\s+VM\s+\(ANGSTROMS\*\*3/DA\):\s+(\d+\.\d+)' ) , 'matthews' ) sc = ( compile ( 'REMARK 280\s+SOLVENT CONTENT,\s+VS\s+\(%\):\s+(\d+\.\d+)' ) , 'solvent_content' ) sg = ( compile ( 'REMARK 290\s+SYMMETRY OPERATORS FOR SPACE GROUP:\s+(.*\S)' ) , 'space_group' ) xt = ( compile ( 'REMARK 200\s+EXPERIMENT TYPE\s+:\s+(.*\S)' ) , 'experiment_type' ) rs = ( compile ( 'REMARK   2\s+RESOLUTION\.\s+(\d+\.\d+)\s+ANGSTROMS\.' ) , 'resolution' ) rf = ( compile ( 'REMARK   3\s+FREE R VALUE\s+:\s+(\d+\.\d+)' ) , 'r_free' ) xd = ( compile ( 'EXPDTA\s+([\w\-]+).*' ) , 'expdta' ) c1 = ( compile ( 'CRYST1\s+((\d+\.\d+\s+){6})' ) , 'cryst1' ) ra = ( compile ( 'DBREF\s+\S{4}\s+\S\s+\d+\s+\d+\s+\S+\s+(\S+)\s+\S+\s+\d+\s+\d+\s+$' ) , 'dbref_acc' ) rx = ( compile ( 'DBREF\s+\S{4}\s+\S\s+\d+\s+\d+\s+\S+\s+\S+\s+(\S+)\s+\d+\s+\d+\s+$' ) , 'dbref_acc_full' ) tests = [ id , dt , nm , mc , sc , sg , xt , rs , rf , xd , c1 , ra , rx ] results = { } for line in header : for ( regexp , name ) in tests : try : results . update ( { name : regexp . search ( line ) . group ( 1 ) . strip ( ) } ) continue except AttributeError : pass return results
short_docstring: Parse parts of the PDB header.
short_docstring_tokens: Parse parts of the PDB header .
comment: """Parse parts of the PDB header."""$SEP$#CRYST1   60.456   60.456   82.526  90.00  90.00  90.00 P 41          4$SEP$#DBREF  1UI9 A    1   122  UNP    Q84FH6   Q84FH6_THETH     1    122             \n'$SEP$# taking only the first grep.