Parse the atom tag data.
513414
def parse_atom_tag_data(self, name, tag_content):
        ''''''
        current_atom_site = self.current_atom_site
        if current_atom_site.IsHETATM:
            # Early out - do not parse HETATM records
            return

        elif name == 'PDBx:atom_site':
            # We have to handle the atom_site close tag here since we jump based on self._BLOCK first in end_element

            #'''Add the residue to the residue map.'''
            self._BLOCK = None
            current_atom_site = self.current_atom_site
            current_atom_site.validate()
            if current_atom_site.IsATOM:
                # Only parse ATOM records
                r, seqres, ResidueAA, Residue3AA = current_atom_site.convert_to_residue(self.modified_residues)
                if r:
                    if not(self.pdb_id in cases_with_ACE_residues_we_can_ignore and Residue3AA == 'ACE'):
                        # skip certain ACE residues
                        full_residue_id = str(r)
                        if self._residues_read.get(full_residue_id):
                            assert(self._residues_read[full_residue_id] == (r.ResidueAA, seqres))
                        else:
                            self._residues_read[full_residue_id] = (r.ResidueAA, seqres)
                            self._residue_map[r.Chain] = self._residue_map.get(r.Chain, {})
                            assert(type(seqres) == int_type)
                            self._residue_map[r.Chain][str(r)] = seqres

        # Record type
        elif name == 'PDBx:group_PDB':
            # ATOM or HETATM
            if tag_content == 'ATOM':
                current_atom_site.IsATOM = True
            elif tag_content == 'HETATM':
                current_atom_site.IsHETATM = True
            else:
                raise Exception("PDBx:group_PDB was expected to be 'ATOM' or 'HETATM'. '%s' read instead." % tag_content)

        # Residue identifier - chain ID, residue ID, insertion code
        elif name == 'PDBx:auth_asym_id':
            assert(not(current_atom_site.PDBChainID))
            current_atom_site.PDBChainID = tag_content
            if not tag_content:
                assert(current_atom_site.PDBChainIDIsNull)
                if self.pdb_id.upper() == '2MBP':
                    current_atom_site.PDBChainID = 'A' # e.g. 2MBP
                else:
                    current_atom_site.PDBChainID = ' '

        elif name == 'PDBx:auth_seq_id':
            assert(not(current_atom_site.ATOMResidueID))
            current_atom_site.ATOMResidueID = int(tag_content)
        elif name == "PDBx:pdbx_PDB_ins_code":
            if current_atom_site.ATOMResidueiCodeIsNull:
                assert(len(tag_content) == 0)
            else:
                assert(current_atom_site.ATOMResidueiCode == ' ')
                current_atom_site.ATOMResidueiCode = tag_content
        elif name == "PDBx:auth_comp_id":
            assert(not(current_atom_site.ATOMResidueAA))
            current_atom_site.ATOMResidueAA = tag_content

        elif name == "PDBx:label_seq_id":
            assert(not(current_atom_site.SEQRESIndex))
            current_atom_site.SEQRESIndex = int(tag_content)
        elif name == "PDBx:label_comp_id":
            assert(not(current_atom_site.ATOMSeqresResidueAA))
            current_atom_site.ATOMSeqresResidueAA = tag_content
265866
private void parseTag() throws IOException {
        if (dataPos == dataSize)
            return;
        if (isEOC(data[dataPos]) && (data[dataPos + 1] == 0)) {
            int numOfEncapsulatedLenBytes = 0;
            Object elem = null;
            int index;
            for (index = ndefsList.size()-1; index >= 0; index--) {
                // Determine the first element in the vector that does not
                // have a matching EOC
                elem = ndefsList.get(index);
                if (elem instanceof Integer) {
                    break;
                } else {
                    numOfEncapsulatedLenBytes += ((byte[])elem).length - 3;
                }
            }
            if (index < 0) {
                throw new IOException("EOC does not have matching " +
                                      "indefinite-length tag");
            }
            int sectionLen = dataPos - ((Integer)elem).intValue() +
                             numOfEncapsulatedLenBytes;
            byte[] sectionLenBytes = getLengthBytes(sectionLen);
            ndefsList.set(index, sectionLenBytes);
            unresolved--;

            // Add the number of bytes required to represent this section
            // to the total number of length bytes,
            // and subtract the indefinite-length tag (1 byte) and
            // EOC bytes (2 bytes) for this section
            numOfTotalLenBytes += (sectionLenBytes.length - 3);
        }
        dataPos++;
    }
1350666
def parse_singular_string(t, tag_name):
    ''''''
    pos = t.getElementsByTagName(tag_name)
    assert(len(pos) == 1)
    pos = pos[0]
    assert(len(pos.childNodes) == 1)
    return pos.childNodes[0].data
740895
def user_parse(data):
        """"""
        yield 'id', data.get('uuid')
        yield 'username', data.get('username')
        yield 'last_name', data.get('display_name')
        links = data.get('links', {})
        yield 'picture', links.get('avatar', {}).get('href')
        yield 'link', links.get('html', {}).get('href')
576216
function() {
      var data = this.parsed;
      var piece = data[data.length - 1],
        len = piece.length;
      return piece[len - 1] || (piece[len - 1] = {
        tag: "*"
      });
    }
443345
def _parse(self):
        """"""
        with open(self.filename, 'r') as fobj:
            lines = fobj.read().split('\n')

        # Create a header object with content at start of file
        self.header = MOPHeader(self.subfmt).parser(lines)

        # Create a data attribute to hold an astropy.table.Table object
        self.data = MOPDataParser(self.header).parse(lines)
842784
def _handle_tag_data(self, data, text):
        """"""
        for chunk in self.tag_splitter.split(text):
            if not chunk:
                continue
            if data.context & data.CX_NAME:
                if chunk in self.MARKERS or chunk.isspace():
                    self._fail_route()  # Tags must start with text, not spaces
                data.context = data.CX_NOTE_SPACE
            elif chunk.isspace():
                self._handle_tag_space(data, chunk)
                continue
            elif data.context & data.CX_NOTE_SPACE:
                if data.context & data.CX_QUOTED:
                    data.context = data.CX_ATTR_VALUE
                    self._memoize_bad_route()
                    self._pop()
                    self._head = data.reset - 1  # Will be auto-incremented
                    return  # Break early
                self._fail_route()
            elif data.context & data.CX_ATTR_READY:
                data.context = data.CX_ATTR_NAME
                self._push(contexts.TAG_ATTR)
            elif data.context & data.CX_ATTR_NAME:
                if chunk == "=":
                    data.context = data.CX_ATTR_VALUE | data.CX_NOTE_QUOTE
                    self._emit(tokens.TagAttrEquals())
                    continue
                if data.context & data.CX_NOTE_EQUALS:
                    self._push_tag_buffer(data)
                    data.context = data.CX_ATTR_NAME
                    self._push(contexts.TAG_ATTR)
            else:  # data.context & data.CX_ATTR_VALUE assured
                escaped = self._read(-1) == "\\" and self._read(-2) != "\\"
                if data.context & data.CX_NOTE_QUOTE:
                    data.context ^= data.CX_NOTE_QUOTE
                    if chunk in "'\"" and not escaped:
                        data.context |= data.CX_QUOTED
                        data.quoter = chunk
                        data.reset = self._head
                        try:
                            self._push(self._context)
                        except BadRoute:
                            # Already failed to parse this as a quoted string
                            data.context = data.CX_ATTR_VALUE
                            self._head -= 1
                            return
                        continue
                elif data.context & data.CX_QUOTED:
                    if chunk == data.quoter and not escaped:
                        data.context |= data.CX_NOTE_SPACE
                        continue
            self._handle_tag_text(chunk)
927362
def Parse(self):
    """"""
    for data in self.Query(self.EVENTS_QUERY):
      (timestamp, agent_bundle_identifier, agent_name, url, sender,
       sender_address, type_number, title, referrer, referrer_alias) = data
      yield [
          timestamp, "OSX_QUARANTINE", url, referrer, title, agent_name,
          agent_bundle_identifier, sender, sender_address, type_number,
          referrer_alias
      ]
1371006
def _parse(data, obj_name, attr_map):
    """"""
    parsed_xml = minidom.parseString(data)
    parsed_objects = []
    for obj in parsed_xml.getElementsByTagName(obj_name):
        parsed_obj = {}
        for (py_name, xml_name) in attr_map.items():
            parsed_obj[py_name] = _get_minidom_tag_value(obj, xml_name)
        parsed_objects.append(parsed_obj)
    return parsed_objects
569130
def _parse_tagfile(self):
        """"""
        rules = None
        tag = None
        for line in self.original:
            match = self.TAG_DECL_LINE.match(line)
            if match:
                if tag and rules:
                    yield tag, rules
                rules = []
                tag = match.group(1)
                continue

            match = self.TAG_RULE_LINE.match(line)
            if match:
                source = match.group(1)
                rules.append(self._parse_query(source))
1042621
def parse_atoms(self, pdb):
    """"""
    
    atomre = re.compile("ATOM")
    
    atomlines = [line for line in pdb.lines if atomre.match(line)]
    
    chainresnums = {}
    
    for line in atomlines:
      chain = line[21]
      resname = line[17:20]
      resnum = line[22:27]
      #print resnum
      chainresnums.setdefault(chain, [])
      
      if resnum in chainresnums[chain]:
        assert self[chain][chainresnums[chain].index(resnum)] == resname
      else:
        if resnum[-1] == ' ':
          self.setdefault(chain, [])
          self[chain] += [resname]
          chainresnums[chain] += [resnum]
    
    return chainresnums
511048
def data(self):
        """"""
        if self._data is None:
            # reset after possible parsing failure
            self.__init__(self.tokens)
            return self._parse()
        else:
            return self._data
146936
def parse(data = nil)
      data ||= @raw_data
    
      # wrapper array holding hashes of css tags/rules
      css_out = []
      # clear initial spaces
      data.strip_side_space!.strip_space!
    
      # split on end of assignments
      data.split('}').each_with_index do |assignments, index|
        # split again to separate tags from rules
        tags, styles = assignments.split('{').map{|a| a.strip_side_space!}
        unless styles.blank?
          # clean up tags and apply namespaces as needed
          tags.strip_selector_space!
          tags.gsub!(/\./, ".#{namespace}") unless namespace.blank?
      
          # split on semicolon to iterate through each rule
          rules = []
          styles.split(';').each do |key_val_pair|
            unless key_val_pair.nil?
              # split by property/val and append to rules array with correct declaration
              property, value = key_val_pair.split(':', 2).map{|kv| kv.strip_side_space!}
              break unless property && value
              rules << "#{property}:#{value};"
            end
          end
          # now keeps track of index as hashes don't keep track of position (which will be fixed in Ruby 1.9)
          css_out << {:tags => tags, :rules => rules.join, :idx => index} unless tags.blank? || rules.to_s.blank?
        end
      end
      css_out
    end
795366
def _parse_residue(self, residue):
        
        
        # Filter Element Nodes
        childs = [ child for child in residue.childNodes if child.nodeType == child.ELEMENT_NODE ]
        
        # Parse info out
        resi = int(childs[0].firstChild.data.strip())
        resn = childs[1].firstChild.data.strip()
        icode = childs[3].firstChild.data
        chain = childs[4].firstChild.data.strip()
        model = int(childs[5].firstChild.data.strip())
        atoms = childs[6:]
        
        # Output
        
        return {'name':  resn,  'number': resi,
                'icode': icode, 'chain':  chain, 
                'model': model, 'atoms': atoms}
1031608
def proc_atom(self):
        """"""
        atom_data = self.proc_line_coordinate(self.current_line)
        (at_type, at_ser, at_name, alt_loc, res_name, chain_id, res_seq,
         i_code, x, y, z, occupancy, temp_factor, element, charge) = atom_data
        # currently active state
        a_state = self.pdb_parse_tree['data'][self.state]
        res_id = (res_seq, i_code)
        if chain_id not in a_state:
            a_state[chain_id] = (set(), OrderedDict())
        if res_id not in a_state[chain_id][1]:
            a_state[chain_id][1][res_id] = (set(), OrderedDict())
        if at_type == 'ATOM':
            if res_name in standard_amino_acids.values():
                poly = 'P'
            else:
                poly = 'N'
        else:
            poly = 'H'
        a_state[chain_id][0].add((chain_id, at_type, poly))
        a_state[chain_id][1][res_id][0].add(
            (at_type, res_seq, res_name, i_code))
        if at_ser not in a_state[chain_id][1][res_id][1]:
            a_state[chain_id][1][res_id][1][at_ser] = [atom_data]
        else:
            a_state[chain_id][1][res_id][1][at_ser].append(atom_data)
        return
1266483
def parse_tag_info(self, f):
        
        # General Stats Table
        tag_info = dict()
        for l in f['f']:
            s = l.split("=")
            if len(s) > 1:
                if s[0].strip() == 'genome':
                    ss = s[1].split("\t")
                    if len(ss) > 2:
                        tag_info['genome'] = ss[0].strip()
                        try:
                            tag_info['UniqPositions'] = float(ss[1].strip())
                            tag_info['TotalPositions'] = float(ss[2].strip())
                        except:
                            tag_info['UniqPositions'] = ss[1].strip()
                            tag_info['TotalPositions'] = ss[2].strip()
                try:
                    tag_info[s[0].strip()] = float(s[1].strip())
                except ValueError:
                    tag_info[s[0].strip()] = s[1].strip()
        return tag_info
486684
def parse(self, xmp):
        """"""
        tree = etree.fromstring(xmp)
        rdf_tree = tree.find(RDF_NS + 'RDF')
        meta = defaultdict(dict)
        for desc in rdf_tree.findall(RDF_NS + 'Description'):
            for el in desc.getchildren():
                ns, tag = self._parse_tag(el)
                value = self._parse_value(el)
                meta[ns][tag] = value
        return dict(meta)