ajtree.c


Function ajTreeNew

Creates a new general tree.

Synopsis

Prototype
AjPTree ajTreeNew (
      void
);

TypeNameRead/WriteDescription
AjPTree RETURNnew tree;

Returns
AjPTree:new tree;

Description

Creates a new general tree.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeNewNewick

Creates a new general tree using a Newick's format phylogenetic tree as input

Synopsis

Prototype
AjPTree ajTreeNewNewick (
      const AjPStr newick
);

TypeNameRead/WriteDescription
const AjPStrnewickInputNewick's format tree
AjPTree RETURNnew tree;

Input
newick:(Input)Newick's format tree
Returns
AjPTree:new tree;

Description

Creates a new general tree using a Newick's format phylogenetic tree as input

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrNew

Creates a new string tree.

Synopsis

Prototype
AjPTree ajTreestrNew (
      void
);

TypeNameRead/WriteDescription
AjPTree RETURNnew tree;

Returns
AjPTree:new tree;

Description

Creates a new string tree.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrCopy

Copy a string tree.

WARNING: pointers to the data are copied, NOT the data so be careful when cleaning up after copy.

Synopsis

Prototype
AjPTree ajTreestrCopy (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree to be copied
AjPTree RETURNNew, copied, tree.

Input
thys:(Input)Tree to be copied
Returns
AjPTree:New, copied, tree.

Description

Copy a string tree.

WARNING: pointers to the data are copied, NOT the data so be careful when cleaning up after copy.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeCopy

Copy a tree.

WARNING: pointers to the data are copied, NOT the data so be careful when cleaning up after copy.

Synopsis

Prototype
AjPTree ajTreeCopy (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputtree to be copied
AjPTree RETURNnew copied tree.

Input
thys:(Input)tree to be copied
Returns
AjPTree:new copied tree.

Description

Copy a tree.

WARNING: pointers to the data are copied, NOT the data so be careful when cleaning up after copy.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeLength

get the number of nodes in the linked tree.

Synopsis

Prototype
ajuint ajTreeLength (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree
ajuint RETURNNumber of nodes in tree.

Input
thys:(Input)Tree
Returns
ajuint:Number of nodes in tree.

Description

get the number of nodes in the linked tree.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrLength

get the number of nodes in the linked tree.

Synopsis

Prototype
ajuint ajTreestrLength (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree
ajuint RETURNNumber of nodes in tree.

Input
thys:(Input)Tree
Returns
ajuint:Number of nodes in tree.

Description

get the number of nodes in the linked tree.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeFree

Free all nodes in the tree. NOTE: The data is only freed with a specified tree type. For undefined data types we recommend you to use ajTreeMap with a routine to free the memory.

Synopsis

Prototype
void ajTreeFree (
      AjPTree* pthis
);

TypeNameRead/WriteDescription
AjPTree*pthisDeleteTree
void RETURN

Output
pthis:(Delete)Tree
Returns
void:No return value

Description

Free all nodes in the tree. NOTE: The data is only freed with a specified tree type. For undefined data types we recommend you to use ajTreeMap with a routine to free the memory.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrFree

Free all nodes in a string tree. Also deletes all the strings. If these are to be preserved, use ajTreestrDel instead.

Synopsis

Prototype
void ajTreestrFree (
      AjPTree* pthis
);

TypeNameRead/WriteDescription
AjPTree*pthisDeleteTree
void RETURN

Output
pthis:(Delete)Tree
Returns
void:No return value

Description

Free all nodes in a string tree. Also deletes all the strings. If these are to be preserved, use ajTreestrDel instead.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeDel

Free the tree. Do not attempt to free the nodes. For use where the node data has been saved elsewhere, for example by ajTreeToArray or where the tree is a temporary structure referring to permanent data.

Synopsis

Prototype
void ajTreeDel (
      AjPTree* pthis
);

TypeNameRead/WriteDescription
AjPTree*pthisDeleteTree
void RETURN

Output
pthis:(Delete)Tree
Returns
void:No return value

Description

Free the tree. Do not attempt to free the nodes. For use where the node data has been saved elsewhere, for example by ajTreeToArray or where the tree is a temporary structure referring to permanent data.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrDel

Free the tree. Do not attempt to free the nodes. For use where the node data has been saved elsewhere, for example by ajTreeToArray or where the tree is a temporary structure referring to permanent data.

Synopsis

Prototype
void ajTreestrDel (
      AjPTree* pthis
);

TypeNameRead/WriteDescription
AjPTree*pthisDeleteTree
void RETURN

Output
pthis:(Delete)Tree
Returns
void:No return value

Description

Free the tree. Do not attempt to free the nodes. For use where the node data has been saved elsewhere, for example by ajTreeToArray or where the tree is a temporary structure referring to permanent data.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeMap

For each data node in the tree call function apply.

Synopsis

Prototype
void ajTreeMap (
      AjPTree thys,
      void function apply,
      void* cl
);

TypeNameRead/WriteDescription
AjPTreethysModifyTree.
void functionapplyFunctionFunction to call for each tree item.
void*clModifyStandard, usually NULL.
void RETURN

Input
apply:(Function)Function to call for each tree item.
Input & Output
thys:(Modify)Tree.
cl:(Modify)Standard, usually NULL.
Returns
void:No return value

Description

For each data node in the tree call function apply.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrMap

For each node in the tree call function apply, with the address of the string and a client pointer.

Synopsis

Prototype
void ajTreestrMap (
      AjPTree thys,
      void function apply,
      void* cl
);

TypeNameRead/WriteDescription
AjPTreethysModifyTree.
void functionapplyFunctionFunction to call for each tree item.
void*clModifyStandard, usually NULL.
void RETURN

Input
apply:(Function)Function to call for each tree item.
Input & Output
thys:(Modify)Tree.
cl:(Modify)Standard, usually NULL.
Returns
void:No return value

Description

For each node in the tree call function apply, with the address of the string and a client pointer.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeToArray

Create an array of the pointers to the data.

Synopsis

Prototype
ajuint ajTreeToArray (
      const AjPTree thys,
      void*** array
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree
void***arrayOutputArray of pointers to tree items.
ajuint RETURNSize of array of pointers.

Input
thys:(Input)Tree
Output
array:(Output)Array of pointers to tree items.
Returns
ajuint:Size of array of pointers.

Description

Create an array of the pointers to the data.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrToArray

Create an array of the pointers to the data.

Synopsis

Prototype
ajuint ajTreestrToArray (
      const AjPTree thys,
      AjPStr** array
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree
AjPStr**arrayOutputArray of Strings.
ajuint RETURNSize of array of pointers.

Input
thys:(Input)Tree
Output
array:(Output)Array of Strings.
Returns
ajuint:Size of array of pointers.

Description

Create an array of the pointers to the data.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeDummyFunction

Dummy function to catch all unused functions defined in ajtree

Synopsis

Prototype
void ajTreeDummyFunction (
      void
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

Description

Dummy function to catch all unused functions defined in ajtree

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeAddData

Sets the data value in a terminal tree node.

Synopsis

Prototype
AjBool ajTreeAddData (
      AjPTree thys,
      const AjPStr name,
      void* data
);

TypeNameRead/WriteDescription
AjPTreethysModifyTerminal tree node. Must have no descendants
const AjPStrnameInputLeaf name
void*dataUnknownData value
AjBool RETURNajTrue on success

Input
name:(Input)Leaf name
Input & Output
thys:(Modify)Terminal tree node. Must have no descendants
Returns
AjBool:ajTrue on success

Description

Sets the data value in a terminal tree node.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrAddData

Sets the data value in a terminal string tree node.

Synopsis

Prototype
AjBool ajTreestrAddData (
      AjPTree thys,
      const AjPStr name,
      AjPStr data
);

TypeNameRead/WriteDescription
AjPTreethysModifyTerminal tree node. Must have no descendants
const AjPStrnameInputLeaf name
AjPStrdataUnknownData value
AjBool RETURNajTrue on success

Input
name:(Input)Leaf name
Input & Output
thys:(Modify)Terminal tree node. Must have no descendants
Returns
AjBool:ajTrue on success

Description

Sets the data value in a terminal string tree node.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeAddNode

Creates a new child node of the parent

Synopsis

Prototype
AjPTree ajTreeAddNode (
      AjPTree thys
);

TypeNameRead/WriteDescription
AjPTreethysModifyParent tree node
AjPTree RETURNNew tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Input & Output
thys:(Modify)Parent tree node
Returns
AjPTree:New tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Description

Creates a new child node of the parent

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeAddSubNode

Creates a new sibling node of the parent

Synopsis

Prototype
AjPTree ajTreeAddSubNode (
      AjPTree thys
);

TypeNameRead/WriteDescription
AjPTreethysModifyLeft tree node
AjPTree RETURNNew tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Input & Output
thys:(Modify)Left tree node
Returns
AjPTree:New tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Description

Creates a new sibling node of the parent

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeToNewick

Prints a trace of a tree to debug output

Synopsis

Prototype
void ajTreeToNewick (
      const AjPTree thys,
      AjPStr* Pnewick
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree object
AjPStr*PnewickOutputNewick format string
void RETURN

Input
thys:(Input)Tree object
Output
Pnewick:(Output)Newick format string
Returns
void:No return value

Description

Prints a trace of a tree to debug output

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeTrace

Prints a trace of a tree to debug output

Synopsis

Prototype
void ajTreeTrace (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree object
void RETURN

Input
thys:(Input)Tree object
Returns
void:No return value

Description

Prints a trace of a tree to debug output

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreestrTrace

Prints a trace of a string tree to debug output

Synopsis

Prototype
void ajTreestrTrace (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputTree object
void RETURN

Input
thys:(Input)Tree object
Returns
void:No return value

Description

Prints a trace of a string tree to debug output

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeFollow

Returns the next node through the tree.

Step down to children, and follow siblings to the right.

When done at any level, go up and right.

Stop when back up at the original parent node.

Synopsis

Prototype
AjPTree ajTreeFollow (
      const AjPTree thys,
      const AjPTree parent
);

TypeNameRead/WriteDescription
const AjPTreethysInputCurrent tree node
const AjPTreeparentInputParent tree node
AjPTree RETURNNew tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Input
thys:(Input)Current tree node
parent:(Input)Parent tree node
Returns
AjPTree:New tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Description

Returns the next node through the tree.

Step down to children, and follow siblings to the right.

When done at any level, go up and right.

Stop when back up at the original parent node.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeNext

Returns the next node at the same level

Synopsis

Prototype
AjPTree ajTreeNext (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputParent tree node
AjPTree RETURNNew tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Input
thys:(Input)Parent tree node
Returns
AjPTree:New tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Description

Returns the next node at the same level

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreePrev

Returns the previous node at the same level

Synopsis

Prototype
AjPTree ajTreePrev (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputParent tree node
AjPTree RETURNNew tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Input
thys:(Input)Parent tree node
Returns
AjPTree:New tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Description

Returns the previous node at the same level

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeDown

Returns the next node down 1 level

Synopsis

Prototype
AjPTree ajTreeDown (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputParent tree node
AjPTree RETURNNew tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Input
thys:(Input)Parent tree node
Returns
AjPTree:New tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Description

Returns the next node down 1 level

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeUp

Returns the parent of the present node

Synopsis

Prototype
AjPTree ajTreeUp (
      const AjPTree thys
);

TypeNameRead/WriteDescription
const AjPTreethysInputChild tree node
AjPTree RETURNNew tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Input
thys:(Input)Child tree node
Returns
AjPTree:New tree node created. It has no data value so far, so ajTreeAddNode or ajTreeAddData should be called to define data or further nodes.

Description

Returns the parent of the present node

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTreeExit

Prints a summary of tree usage with debug calls

Synopsis

Prototype
void ajTreeExit (
      void
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

Description

Prints a summary of tree usage with debug calls

See Also

See other functions in this section

Availability

In release 6.4.0