Structural Bioinformatics Library
Template C++ / Python API for developping structural bioinformatics applications.
PALSE_xml_DB Class Reference

Constructions

def __init__ (self)
 Default constructor. More...
 

Internal Methods

def __len__ (self)
 Number of trees in the database. More...
 
def append (self, et)
 Add a etree to the database. More...
 
def add_XML_etree (self, my_tree, tree_name)
 Add the given Element tree into the database (at the last position). More...
 

Load Files

def load_from_directory (self, input_dir, regex="", subdirs=False)
 Parse the input directory, possibly filter the filenames, and build one ETree for each file retained. More...
 
def sort_databases (self, varname, type=str, options_suffix="__options.xml")
 Sorts input databases by looking for each of them its corresponding options.xml file, and sorting following the value of the described option. More...
 
def add_pdb_namespaces (self)
 Add all namespaces specific to xml files from PDB. More...
 
def add_namespace (self, prefix, uri)
 Add a namespace represented by a URI and its prefix. More...
 

Boost Archive Identifiers

def __collect_boost_ids_recursive__ (self, tree, id_dict)
 Collect the ids recursively in a tree, exploring all the subtrees. More...
 
def __duplicate_boost_id_reference_recursive__ (self, tree, id_dict)
 In a tree, replace the boost id references for which the id exists in the dictionary. More...
 
def duplicate_boost_archive_references (self)
 If any references in a boost archive, replace them by copy of initial objects. More...
 

Hierarchy of Dataset

def __get_path_recursive__ (self, tree, path, paths)
 get_path_recursive More...
 
def __get_intersection_of_paths__ (self, paths_1, paths_2)
 get_intersection_of_paths More...
 
def __make_path_strings_as_list_recursive__ (self, path, paths)
 make_path_strings_as_list_recursive More...
 
def __make_path_strings_as_xml_recursive__ (self, deepness, paths)
 make_path_strings_as_xml_recursive More...
 
def get_common_hierarchy (self)
 Return the different paths that are common to all XML files in the dataset as a dictionnary. More...
 
def get_common_hierarchy_as_xml (self)
 Return the different paths that are common to all XML files in the dataset as a list of paths. More...
 
def get_common_hierarchy_as_list (self)
 Return the different paths that are common to all XML files in the dataset as a XML file. More...
 

Queries

def convert_prefix_to_uri (self, xpath_query)
 Convert all registered prefixes in the query to their associated URI. More...
 
def get_attribute (self, xpath_query)
 Returns the following pair: first, a boolean that is True iff the XPath query points to the attribute of a tag; second, if first is True, it is the attribute. More...
 
def get_all_elements_from_root (self, xpath_query, root)
 Retrieves the list of all the elements matching the XPath query from the given root. More...
 
def get_all_elements_from_tree (self, xpath_query, my_tree)
 Retrieves the list of all the elements matching the XPath query in the given ETree. More...
 
def get_all_elements_from_database (self, xpath_query)
 Retrieves the list of all the elements matching the XPath query in each ETree, and returns them as a list of lists (one list per ETree). More...
 
def is_data_value_in_tree (self, xpath_query, my_tree, data_value, type=str)
 Is the given data_value pointed by the given Xpath query. More...
 
def get_all_data_values_from_root (self, xpath_query, root, type=str)
 Retrieves the list of all the data_values matching the XPath query from the given root. More...
 
def get_all_data_values_from_tree (self, xpath_query, my_tree, type=str)
 Retrieves the list of all the data_values matching the XPath query in the given ETree. More...
 
def get_all_data_values_from_database (self, xpath_query, type=str)
 Retrieves the list of all the data_values matching the XPath query in each ETree, and returns them as a list of lists (one list per ETree) More...
 
def get_all_data_values_from_elements (self, elements, xpath_query, type=str)
 Retrieves the list of all the data_values matching the XPath query in the given list of elements. More...
 
def get_leftmost_data_value_from_tree (self, xpath_query, my_tree, type=str)
 Retrieves the first (leftmost) data_value matching the XPath query in the given ETree. More...
 
def get_leftmost_data_values_from_database (self, xpath_query, type=str)
 Retrieves list of leftmost data_values matching the XPath query over all the ETrees of the database (one leftmost data_value per ETree). More...
 
def get_rightmost_data_value_from_tree (self, xpath_query, my_tree, type=str)
 Retrieves the last (rightmost) data_value matching the XPath query in the given ETree. More...
 
def get_rightmost_data_values_from_database (self, xpath_query, type=str)
 Retrieves list of rightmost data_values matching the XPath query over all the ETrees of the database (one lrightmost data_value per ETree). More...
 
def get_data_source_file (self, xpath_query, data_value, type=str)
 Retrieves the filename list of all XML documents having the given data_value pointed by the given XPath query. More...
 
def get_filenames (self)
 Returns the list of filenames. More...
 

Filtering Elements

def get_all_data_values_from_database_compare_to (self, xpath_query, type, data_value, comp)
 get_all_data_values_from_database_compare_to More...
 
def get_all_data_values_from_database_equal_to (self, xpath_query, type, data_value)
 get_all_data_values_from_database_equal_to More...
 
def get_all_data_values_from_database_lower_than (self, xpath_query, type, data_value)
 get_all_data_values_from_database_lower_than More...
 
def get_all_data_values_from_database_greater_than (self, xpath_query, type, data_value)
 get_all_data_values_from_database_greater_than More...
 
def filter_elements_by_data_values_compare_to (self, elements, xpath_query, data_value, comp)
 Filter the input elements and create a list of filtered elements. More...
 
def filter_elements_by_data_values_equal_to (self, elements, xpath_query, data_value)
 Same as previous but with the equal comparator. More...
 
def filter_elements_by_data_values_lower_than (self, elements, xpath_query, data_value)
 Same as previous but with the less comparator. More...
 
def filter_elements_by_data_values_leq_than (self, elements, xpath_query, data_value)
 Same as previous but with the less or equal comparator. More...
 
def filter_elements_by_data_values_greater_than (self, elements, xpath_query, data_value)
 Same as previous but with the more comparator. More...
 
def filter_elements_by_data_values_geq_than (self, elements, xpath_query, data_value)
 Same as previous but with the more or equal comparator. More...
 

Detailed Description

A class to represent XML files having the same hierarchical structure.

   This class parses a list of xml files, returns
      one Element Tree (ETree) for each of them, and
      stores these in a DB consistin of a list.
      Furthermore, the class allows selecting
      specific elements common to all trees thanks to
      so-called XPath queries.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Default constructor.

Member Function Documentation

◆ __collect_boost_ids_recursive__()

def __collect_boost_ids_recursive__ (   self,
  tree,
  id_dict 
)

Collect the ids recursively in a tree, exploring all the subtrees.

◆ __duplicate_boost_id_reference_recursive__()

def __duplicate_boost_id_reference_recursive__ (   self,
  tree,
  id_dict 
)

In a tree, replace the boost id references for which the id exists in the dictionary.

◆ __get_intersection_of_paths__()

def __get_intersection_of_paths__ (   self,
  paths_1,
  paths_2 
)

get_intersection_of_paths

◆ __get_path_recursive__()

def __get_path_recursive__ (   self,
  tree,
  path,
  paths 
)

get_path_recursive

◆ __len__()

def __len__ (   self)

Number of trees in the database.

◆ __make_path_strings_as_list_recursive__()

def __make_path_strings_as_list_recursive__ (   self,
  path,
  paths 
)

make_path_strings_as_list_recursive

◆ __make_path_strings_as_xml_recursive__()

def __make_path_strings_as_xml_recursive__ (   self,
  deepness,
  paths 
)

make_path_strings_as_xml_recursive

◆ add_namespace()

def add_namespace (   self,
  prefix,
  uri 
)

Add a namespace represented by a URI and its prefix.

◆ add_pdb_namespaces()

def add_pdb_namespaces (   self)

Add all namespaces specific to xml files from PDB.

◆ add_XML_etree()

def add_XML_etree (   self,
  my_tree,
  tree_name 
)

Add the given Element tree into the database (at the last position).

◆ append()

def append (   self,
  et 
)

Add a etree to the database.

◆ convert_prefix_to_uri()

def convert_prefix_to_uri (   self,
  xpath_query 
)

Convert all registered prefixes in the query to their associated URI.

◆ duplicate_boost_archive_references()

def duplicate_boost_archive_references (   self)

If any references in a boost archive, replace them by copy of initial objects.

◆ filter_elements_by_data_values_compare_to()

def filter_elements_by_data_values_compare_to (   self,
  elements,
  xpath_query,
  data_value,
  comp 
)

Filter the input elements and create a list of filtered elements.

For each element in the input list, if there exists a child pointed by the xpath query having as text a number positively compared to the input data_value with the imput comparator, it is added to the filtered output. Note that the pointed data_values have to be convertible to float.

◆ filter_elements_by_data_values_equal_to()

def filter_elements_by_data_values_equal_to (   self,
  elements,
  xpath_query,
  data_value 
)

Same as previous but with the equal comparator.

◆ filter_elements_by_data_values_geq_than()

def filter_elements_by_data_values_geq_than (   self,
  elements,
  xpath_query,
  data_value 
)

Same as previous but with the more or equal comparator.

◆ filter_elements_by_data_values_greater_than()

def filter_elements_by_data_values_greater_than (   self,
  elements,
  xpath_query,
  data_value 
)

Same as previous but with the more comparator.

◆ filter_elements_by_data_values_leq_than()

def filter_elements_by_data_values_leq_than (   self,
  elements,
  xpath_query,
  data_value 
)

Same as previous but with the less or equal comparator.

◆ filter_elements_by_data_values_lower_than()

def filter_elements_by_data_values_lower_than (   self,
  elements,
  xpath_query,
  data_value 
)

Same as previous but with the less comparator.

◆ get_all_data_values_from_database()

def get_all_data_values_from_database (   self,
  xpath_query,
  type = str 
)

Retrieves the list of all the data_values matching the XPath query in each ETree, and returns them as a list of lists (one list per ETree)

◆ get_all_data_values_from_database_compare_to()

def get_all_data_values_from_database_compare_to (   self,
  xpath_query,
  type,
  data_value,
  comp 
)

get_all_data_values_from_database_compare_to

◆ get_all_data_values_from_database_equal_to()

def get_all_data_values_from_database_equal_to (   self,
  xpath_query,
  type,
  data_value 
)

get_all_data_values_from_database_equal_to

◆ get_all_data_values_from_database_greater_than()

def get_all_data_values_from_database_greater_than (   self,
  xpath_query,
  type,
  data_value 
)

get_all_data_values_from_database_greater_than

◆ get_all_data_values_from_database_lower_than()

def get_all_data_values_from_database_lower_than (   self,
  xpath_query,
  type,
  data_value 
)

get_all_data_values_from_database_lower_than

◆ get_all_data_values_from_elements()

def get_all_data_values_from_elements (   self,
  elements,
  xpath_query,
  type = str 
)

Retrieves the list of all the data_values matching the XPath query in the given list of elements.

◆ get_all_data_values_from_root()

def get_all_data_values_from_root (   self,
  xpath_query,
  root,
  type = str 
)

Retrieves the list of all the data_values matching the XPath query from the given root.

◆ get_all_data_values_from_tree()

def get_all_data_values_from_tree (   self,
  xpath_query,
  my_tree,
  type = str 
)

Retrieves the list of all the data_values matching the XPath query in the given ETree.

◆ get_all_elements_from_database()

def get_all_elements_from_database (   self,
  xpath_query 
)

Retrieves the list of all the elements matching the XPath query in each ETree, and returns them as a list of lists (one list per ETree).

◆ get_all_elements_from_root()

def get_all_elements_from_root (   self,
  xpath_query,
  root 
)

Retrieves the list of all the elements matching the XPath query from the given root.

◆ get_all_elements_from_tree()

def get_all_elements_from_tree (   self,
  xpath_query,
  my_tree 
)

Retrieves the list of all the elements matching the XPath query in the given ETree.

◆ get_attribute()

def get_attribute (   self,
  xpath_query 
)

Returns the following pair: first, a boolean that is True iff the XPath query points to the attribute of a tag; second, if first is True, it is the attribute.

◆ get_common_hierarchy()

def get_common_hierarchy (   self)

Return the different paths that are common to all XML files in the dataset as a dictionnary.

Note that only paths that are identical from the root of each XML file are stored.

◆ get_common_hierarchy_as_list()

def get_common_hierarchy_as_list (   self)

Return the different paths that are common to all XML files in the dataset as a XML file.

Note that only paths that are identical from the root of each XML file are stored.

◆ get_common_hierarchy_as_xml()

def get_common_hierarchy_as_xml (   self)

Return the different paths that are common to all XML files in the dataset as a list of paths.

Note that only paths that are identical from the root of each XML file are stored.

◆ get_data_source_file()

def get_data_source_file (   self,
  xpath_query,
  data_value,
  type = str 
)

Retrieves the filename list of all XML documents having the given data_value pointed by the given XPath query.

◆ get_filenames()

def get_filenames (   self)

Returns the list of filenames.

◆ get_leftmost_data_value_from_tree()

def get_leftmost_data_value_from_tree (   self,
  xpath_query,
  my_tree,
  type = str 
)

Retrieves the first (leftmost) data_value matching the XPath query in the given ETree.

◆ get_leftmost_data_values_from_database()

def get_leftmost_data_values_from_database (   self,
  xpath_query,
  type = str 
)

Retrieves list of leftmost data_values matching the XPath query over all the ETrees of the database (one leftmost data_value per ETree).

◆ get_rightmost_data_value_from_tree()

def get_rightmost_data_value_from_tree (   self,
  xpath_query,
  my_tree,
  type = str 
)

Retrieves the last (rightmost) data_value matching the XPath query in the given ETree.

◆ get_rightmost_data_values_from_database()

def get_rightmost_data_values_from_database (   self,
  xpath_query,
  type = str 
)

Retrieves list of rightmost data_values matching the XPath query over all the ETrees of the database (one lrightmost data_value per ETree).

◆ is_data_value_in_tree()

def is_data_value_in_tree (   self,
  xpath_query,
  my_tree,
  data_value,
  type = str 
)

Is the given data_value pointed by the given Xpath query.

◆ load_from_directory()

def load_from_directory (   self,
  input_dir,
  regex = "",
  subdirs = False 
)

Parse the input directory, possibly filter the filenames, and build one ETree for each file retained.

◆ sort_databases()

def sort_databases (   self,
  varname,
  type = str,
  options_suffix = "__options.xml" 
)

Sorts input databases by looking for each of them its corresponding options.xml file, and sorting following the value of the described option.