Taxonomy
public final class Taxonomy
The base class from which all the NCBI related tasks are initiated. This class is not meant to be instantiated but it serves as a start node to invoke the TaxonomyKit functions in your code.
-
Sends an asynchronous request to the NCBI servers asking for every taxon identifier that matches a specific query.
Since
TaxonomyKit 1.0.Warning
Please note that the callback may not be called on the main thread.
Declaration
Swift
@discardableResult public static func findIdentifiers(for query: String, callback: @escaping(_ result: Result<[TaxonID], TaxonomyError>) -> Void) -> URLSessionDataTask
Parameters
query
The user-entered search query.
callback
A callback closure that will be called when the request completes or when an error occurs. This closure has a
TaxonomyResult<[TaxonID]>
parameter that contains an array with the found IDs when the request succeeds.Return Value
The
URLSessionDataTask
object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point. -
Sends an asynchronous request to the NCBI servers asking for record names spelled similarly to an unmatched query.
Since
TaxonomyKit 1.0.Warning
Please note that the callback may not be called on the main thread.
Declaration
Swift
@discardableResult public static func findSimilarSpelledCandidates(for failedQuery: String, callback: @escaping (_ result: Result<String?, TaxonomyError>) -> Void) -> URLSessionDataTask
Parameters
failedQuery
The user-entered and unmatched search query. If the query is valid, the callback will be called with a
nil
value.callback
A callback closure that will be called when the request completes or when an error occurs. This closure has a
TaxonomyResult<String?>
parameter that contains the first suggested candidate (or nil if no suggestions were made) when the request succeeds.Return Value
The
URLSessionDataTask
object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point. -
Sends an asynchronous request to the NCBI servers asking for the taxon and lineage info for a set of given NCBI internal identifiers.
Since
TaxonomyKit 1.9.Warning
Please note that the callback may not be called on the main thread.Declaration
Swift
@discardableResult public static func downloadTaxa(identifiers: [TaxonID], callback: @escaping (_ result: Result<[Taxon], TaxonomyError>) -> Void) -> URLSessionDataTask
Parameters
identifiers
The NCBI internal identifiers.
callback
A callback closure that will be called when the request completes or when an error occurs. This closure has a
TaxonomyResult<[Taxon]>
parameter that contains the retrieved taxon when the request succeeds.Return Value
The
URLSessionDataTask
object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point. -
Sends an asynchronous request to the NCBI servers asking for a taxon’s immediate descendants matches a specific query.
Since
TaxonomyKit 1.8.Warning
Please note that the callback may not be called on the main thread.
Declaration
Swift
@discardableResult public static func downloadImmediateDescendants<T: TaxonRepresenting>(for taxon: T, callback: @escaping(Result<[TaxonLineageItem], TaxonomyError>) -> Void) -> URLSessionDataTask
Parameters
taxon
The taxon whose scientific name will be used to query for descendants.
callback
A callback closure that will be called when the request completes or when an error occurs. This closure has a
TaxonomyResult<[TaxonLineageItem]>
parameter that contains an array with the found descendants when the request succeeds.Return Value
The
URLSessionDataTask
object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point. -
Sends an asynchronous request to the NCBI servers asking for external links related to a given taxon identifier.
Since
TaxonomyKit 1.1.Warning
Please note that the callback may not be called on the main thread.Declaration
Swift
@discardableResult public static func findLinkedResources(for identifier: TaxonID, callback: @escaping (Result<[ExternalLink], TaxonomyError>) -> Void) -> URLSessionDataTask
Parameters
id
The NCBI internal identifier.
callback
A callback closure that will be called when the request completes or if an error occurs. This closure has a
TaxonomyResult<[ExternalLink]>
parameter that contains an array with the retrieved links when the request succeeds.Return Value
The
URLSessionDataTask
object that has begun handling the request. You may keep a reference to this object if you plan it should be canceled at some point.