nodes: 0, module; 1, function_definition; 2, function_name:from_str; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:input_string; 7, identifier:fmt; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, import_from_statement; 13, import_from_statement; 14, import_from_statement; 15, import_from_statement; 16, import_from_statement; 17, expression_statement; 18, if_statement; 19, if_statement; 20, if_statement; 21, return_statement; 22, identifier:primitive; 23, False; 24, identifier:sort; 25, False; 26, identifier:merge_tol; 27, float:0.0; 28, comment:"""
          Reads a structure from a string.
  
          Args:
              input_string (str): String to parse.
              fmt (str): A format specification.
              primitive (bool): Whether to find a primitive cell. Defaults to
                  False.
              sort (bool): Whether to sort the sites in accordance to the default
                  ordering criteria, i.e., electronegativity.
              merge_tol (float): If this is some positive number, sites that
                  are within merge_tol from each other will be merged. Usually
                  0.01 should be enough to deal with common numerical issues.
  
          Returns:
              IStructure / Structure
          """; 29, dotted_name; 30, dotted_name; 31, dotted_name; 32, dotted_name; 33, dotted_name; 34, dotted_name; 35, dotted_name; 36, dotted_name; 37, dotted_name; 38, dotted_name; 39, assignment; 40, comparison_operator:fmt == "cif"; 41, block; 42, elif_clause; 43, elif_clause; 44, elif_clause; 45, elif_clause; 46, elif_clause; 47, elif_clause; 48, else_clause; 49, identifier:sort; 50, block; 51, identifier:merge_tol; 52, block; 53, call; 54, identifier:pymatgen; 55, identifier:io; 56, identifier:cif; 57, identifier:CifParser; 58, identifier:pymatgen; 59, identifier:io; 60, identifier:vasp; 61, identifier:Poscar; 62, identifier:pymatgen; 63, identifier:io; 64, identifier:cssr; 65, identifier:Cssr; 66, identifier:pymatgen; 67, identifier:io; 68, identifier:xcrysden; 69, identifier:XSF; 70, identifier:pymatgen; 71, identifier:io; 72, identifier:atat; 73, identifier:Mcsqs; 74, identifier:fmt; 75, call; 76, identifier:fmt; 77, string:"cif"; 78, expression_statement; 79, expression_statement; 80, comparison_operator:fmt == "poscar"; 81, block; 82, comparison_operator:fmt == "cssr"; 83, block; 84, comparison_operator:fmt == "json"; 85, block; 86, comparison_operator:fmt == "yaml"; 87, block; 88, comparison_operator:fmt == "xsf"; 89, block; 90, comparison_operator:fmt == "mcsqs"; 91, block; 92, block; 93, expression_statement; 94, expression_statement; 95, attribute; 96, argument_list; 97, attribute; 98, argument_list; 99, assignment; 100, assignment; 101, identifier:fmt; 102, string:"poscar"; 103, expression_statement; 104, identifier:fmt; 105, string:"cssr"; 106, expression_statement; 107, expression_statement; 108, identifier:fmt; 109, string:"json"; 110, expression_statement; 111, expression_statement; 112, identifier:fmt; 113, string:"yaml"; 114, import_statement; 115, expression_statement; 116, expression_statement; 117, identifier:fmt; 118, string:"xsf"; 119, expression_statement; 120, identifier:fmt; 121, string:"mcsqs"; 122, expression_statement; 123, raise_statement; 124, assignment; 125, call; 126, identifier:cls; 127, identifier:from_sites; 128, identifier:s; 129, identifier:fmt; 130, identifier:lower; 131, identifier:parser; 132, call; 133, identifier:s; 134, subscript; 135, assignment; 136, assignment; 137, assignment; 138, assignment; 139, assignment; 140, aliased_import; 141, assignment; 142, assignment; 143, assignment; 144, assignment; 145, call; 146, identifier:s; 147, call; 148, attribute; 149, argument_list; 150, attribute; 151, argument_list; 152, call; 153, integer:0; 154, identifier:s; 155, attribute; 156, identifier:cssr; 157, call; 158, identifier:s; 159, attribute; 160, identifier:d; 161, call; 162, identifier:s; 163, call; 164, dotted_name; 165, identifier:yaml; 166, identifier:d; 167, call; 168, identifier:s; 169, call; 170, identifier:s; 171, attribute; 172, identifier:s; 173, call; 174, identifier:ValueError; 175, argument_list; 176, attribute; 177, argument_list; 178, identifier:s; 179, identifier:merge_sites; 180, identifier:merge_tol; 181, identifier:CifParser; 182, identifier:from_string; 183, identifier:input_string; 184, attribute; 185, argument_list; 186, call; 187, identifier:structure; 188, attribute; 189, argument_list; 190, identifier:cssr; 191, identifier:structure; 192, attribute; 193, argument_list; 194, attribute; 195, argument_list; 196, identifier:ruamel; 197, identifier:yaml; 198, attribute; 199, argument_list; 200, attribute; 201, argument_list; 202, call; 203, identifier:structure; 204, attribute; 205, argument_list; 206, binary_operator:"Unrecognized format `%s`!" % fmt; 207, identifier:s; 208, identifier:get_sorted_structure; 209, identifier:parser; 210, identifier:get_structures; 211, keyword_argument; 212, attribute; 213, argument_list; 214, identifier:Cssr; 215, identifier:from_string; 216, identifier:input_string; 217, identifier:json; 218, identifier:loads; 219, identifier:input_string; 220, identifier:Structure; 221, identifier:from_dict; 222, identifier:d; 223, identifier:yaml; 224, identifier:safe_load; 225, identifier:input_string; 226, identifier:Structure; 227, identifier:from_dict; 228, identifier:d; 229, attribute; 230, argument_list; 231, identifier:Mcsqs; 232, identifier:structure_from_string; 233, identifier:input_string; 234, string:"Unrecognized format `%s`!"; 235, identifier:fmt; 236, identifier:primitive; 237, identifier:primitive; 238, identifier:Poscar; 239, identifier:from_string; 240, identifier:input_string; 241, False; 242, keyword_argument; 243, identifier:XSF; 244, identifier:from_string; 245, identifier:input_string; 246, identifier:read_velocities; 247, False
code: def from_str(cls, input_string, fmt, primitive=False, sort=False,
                   merge_tol=0.0):
          """
          Reads a structure from a string.
  
          Args:
              input_string (str): String to parse.
              fmt (str): A format specification.
              primitive (bool): Whether to find a primitive cell. Defaults to
                  False.
              sort (bool): Whether to sort the sites in accordance to the default
                  ordering criteria, i.e., electronegativity.
              merge_tol (float): If this is some positive number, sites that
                  are within merge_tol from each other will be merged. Usually
                  0.01 should be enough to deal with common numerical issues.
  
          Returns:
              IStructure / Structure
          """
          from pymatgen.io.cif import CifParser
          from pymatgen.io.vasp import Poscar
          from pymatgen.io.cssr import Cssr
          from pymatgen.io.xcrysden import XSF
          from pymatgen.io.atat import Mcsqs
          fmt = fmt.lower()
          if fmt == "cif":
              parser = CifParser.from_string(input_string)
              s = parser.get_structures(primitive=primitive)[0]
          elif fmt == "poscar":
              s = Poscar.from_string(input_string, False,
                                     read_velocities=False).structure
          elif fmt == "cssr":
              cssr = Cssr.from_string(input_string)
              s = cssr.structure
          elif fmt == "json":
              d = json.loads(input_string)
              s = Structure.from_dict(d)
          elif fmt == "yaml":
              import ruamel.yaml as yaml
              d = yaml.safe_load(input_string)
              s = Structure.from_dict(d)
          elif fmt == "xsf":
              s = XSF.from_string(input_string).structure
          elif fmt == "mcsqs":
              s = Mcsqs.structure_from_string(input_string)
          else:
              raise ValueError("Unrecognized format `%s`!" % fmt)
  
          if sort:
              s = s.get_sorted_structure()
          if merge_tol:
              s.merge_sites(merge_tol)
          return cls.from_sites(s)