class MetaAppModel(object): """Overlying application model interface.""" __metaclass__ = ABCMeta started = Event() """Fired when the application starts. Callbacks should look like: .. function:: callback() """ seq_loaded = Event() """Fired when a sequence is loaded from the Entrez triad into the SeqInput triad. Callbacks should look like: .. function:: callback() """ islands_computed = Event() """Fired when island locations have been computed. Callbacks should look like: .. function:: callback() """ @abstractmethod def register_for_events(self): """Register for events fired by other models.""" raise NotImplementedError() @abstractmethod def run(self, argv=None): """Called when the application starts.""" raise NotImplementedError() @abstractmethod def load_file(self, file_path): """Direct pass-through to :func:`MetaSeqInputModel.load_file()`. :param file_path: the path to the sequence file :type file_path: :class:`str` """ raise NotImplementedError()
class MetaEntrezModel(object): seq_loaded = Event() """Fired when a sequence is loaded from the Entrez triad into the SeqInput triad. Callbacks should look like: .. function:: callback() """ @abstractmethod def search(self, text): """Search Entrez database. :param text: the text to search :type text: :class:`str` :return: tuple containing (id_list, query_translation) :rtype: :class:`tuple` """ raise NotImplementedError() @abstractmethod def suggest(self, text): """Suggested Entrez spelling. :param text: unchecked text from input :type text: :class:`str` :return: the suggested text query :rtype: :class:`str` """ raise NotImplementedError() @abstractmethod def get_seq_record(self, index): """Pull sequence based on index. :param index: the index of the sequence :type index: :class:`int` :return: the sequence :rtype: :class:`SeqRecord` """ raise NotImplementedError() @abstractmethod def load_seq(self): """Load the currently selected sequence into SeqInputView.""" raise NotImplementedError()
class BaseAppView(object): file_load_requested = Event() """Called when the user requests to load a file. Callbacks should look like: .. function:: callback(file_path) :param file_path: path the the file to load :type file_path: :class:`str` """ def start(self): """Start the view.""" raise NotImplementedError() def show_seq_input(self): """Show the sequence input view.""" raise NotImplementedError() def show_results(self): """Show the results view.""" raise NotImplementedError()
class MetaResultsModel(object): islands_computed = Event() """Fired when island locations have been computed. Callbacks should look like: .. function:: callback(global_seq, feature_tuples, algo_name, exec_time) :param global_seq: the full sequence :type global_seq: :class:`str` :param feature_tuples: tuples containing locations of the features :type feature_tuples: :class:`list` of :class:`tuple` :param algo_name: the name of the algorithm used :type algo_name: :class:`str` :param exec_time: algorithm's execution duration :type exec_time: :class:`float` """ @abstractmethod def set_results(self, results, algo_name, exec_time): """Set the results of island computation. :param results: algorithm results :type results: :class:`AlgoResults` :param algo_name: the name of the algorithm used :type algo_name: :class:`str` :param exec_time: the algorithm's execution time :type exec_time: :class:`float` """ raise NotImplementedError() @abstractmethod def get_island_info(self, island_index): """Return the island information corresponding to a certain index. :return: island information :rtype: :class:`IslandInfo` """ raise NotImplementedError()
class MetaSeqInputModel(object): __metaclass__ = ABCMeta file_loaded = Event() """Fired after a file has been loaded into memory. Callbacks should look like: .. function:: callback(file_contents) :param file_contents: contents of the loaded file :type file_contents: :class:`str` """ error_raised = Event() """Fired when an error occurs. Callbacks should look like: .. function:: callback(error_message) :param error_message: the error message :type error_message: :class:`str` """ island_definition_defaults_set = Event() """Fired when default island definitions are set. Callbacks should look like: .. function:: callback(island_size, min_gc_ratio) :param island_size: number of bases in the island :type island_size: :class:`int` :param min_gc_ratio: minimum ratio of Guanine/Cytosine :type min_gc_ratio: :class:`float` :param min_obs_exp_cpg_ratio: minimum of observed CpG's to expected :type min_obs_exp_cpg_ratio: :class:`float` """ algorithms_loaded = Event() """Fired when all available algorithms have been loaded. Callbacks should look like: .. function:: callback(algorithm_names) :param algorithm_names: list of algorithm names :type algorithm_names: :class:`list` of :class:`str` """ islands_computed = Event() """Fired when island locations have been computed. Callbacks should look like: .. function:: callback() """ @abstractmethod def set_island_definition_defaults(self): """Set the default island definitions. """ raise NotImplementedError() @abstractmethod def load_algorithms(self): """Load all available algorithms.""" raise NotImplementedError() @abstractmethod def load_file(self, file_path): """Load a sequence file into memory. :param file_path: the path to the sequence file :type file_path: :class:`str` """ raise NotImplementedError() @abstractmethod def compute_islands(self, seq, island_size, min_gc_ratio, min_obs_exp_cpg_ratio, algo_index): """Create a list of CpG island features in a sequence. :param seq: the sequence to analyze :type seq: :class:`Bio.Seq.Seq` :param island_size: the number of bases which an island may contain :type island_size: :class:`int` :param min_gc_ratio: the ratio of GC to other bases :type min_gc_ratio: :class:`float` :param min_obs_exp_cpg_ratio: minimum observed to expected CpG's :type min_obs_exp_cpg_ratio: :class:`float` :param algo_index: the index of the algorithm to use :type algo_index: :class:`int` :raise: :exc:`ValueError` when parameters are invalid """ raise NotImplementedError()
class BaseResultsView(object): island_selected = Event() def set_islands(self, islands): """Set the CpG island locations. :param islands: CpG island locations :type islands: :class:`list` of :class:`tuple` """ raise NotImplementedError() def set_algo_name(self, algo_name): """Set the name of the algorithm used. :param algo_name: the algorithm name :type algo_name: :class:`str` """ raise NotImplementedError() def set_exec_time(self, exec_time_str): """Set the execution time of the algorithm. :param exec_time_str: execution time as a string :type exec_time: :class:`str` """ raise NotImplementedError() def set_global_seq(self, seq_str): """Set the global sequence string. :param seq_str: DNA sequence of feature :type seq_str: :class:`str` """ raise NotImplementedError() def highlight_global_seq(self, start, end): """Highlight the subsequence within the global sequence. :param start: start index of the currently selected island :type start: :class:`str` :param end: end index of the currently selected island :type end: :class:`str` """ raise NotImplementedError() def set_start(self, start_str): """Set start index of the island. :param start_str: start index of island :type start_str: :class:`str` """ raise NotImplementedError() def set_end(self, end_str): """Set end index of the island :param end_str: end index of island :type end_str: :class:`str` """ raise NotImplementedError() def set_length(self, length_str): """Set length of the island. :param length: length of island :type length: :class:`str` """ raise NotImplementedError() def set_subseq(self, seq_str): """Set the subsequence. :param seq_str: DNA sequence of island :type seq_str: :class:`str` """ raise NotImplementedError() def clear_subseq(self): """Clear subsequence field.""" raise NotImplementedError() def set_gc_ratio(self, gc_ratio_str): """Set GC ratio of the island. :param gc_ratio_str: GC ratio of island :type gc_ratio: :class:`str` """ raise NotImplementedError() def set_obs_exp_cpg_ratio(self, obs_exp_cpg_ratio_str): """Set observed/expected CpG ratio of the island. :param obs_exp_cpg_ratio_str: observed/expected ratio :type obs_exp_cpg_ratio_str: :class:`str` """ raise NotImplementedError()
class BaseSeqInputView(object): submitted = Event() """Called when the form is submitted, i.e., submit is clicked by the user. Callbacks should look like: .. function:: callback(seq_str, island_size_str, min_gc_ratio_str) :param seq_str: the sequence as a string :type seq_str: :class:`str` :param island_size_str: number of bases which an island may contain :type island_size_str: :class:`str` :param min_gc_ratio_str: the ratio of GC to other bases :type min_gc_ratio_str: :class:`str` """ def set_seq(self, seq_str): """Set the sequence text. :param seq_str: the sequence in string form :type seq_str: :class:`str` """ raise NotImplementedError() def set_island_size(self, island_size_str): """Set the size of the CpG island. :param island_size: number of bases in the island as a string :type island_size: :class:`str` """ raise NotImplementedError() def set_algorithms(self, algorithm_names): """Set the list of algorithm names. :param algorithm_names: list of algorithm names :type algorithm_names: :class:`list` of :class:`str` """ raise NotImplementedError() def set_min_gc_ratio(self, min_gc_ratio): """Set minimum GC ratio. :param min_gc_ratio: the ratio of Guanine/Cytosine as a string :type min_gc_ratio: :class:`str` """ raise NotImplementedError() def set_min_obs_exp_cpg_ratio(self, min_obs_exp_cpg_ratio): """Set the minimum observed/expected CpG ratio. :param min_gc_ratio: the ratio of Guanine/Cytosine as a string :type min_gc_ratio: :class:`str` """ raise NotImplementedError() def show_error(self, message): """Show the user an error dialog. :param message: error message :type message: :class:`str` """ raise NotImplementedError()
class BaseEntrezView(object): search_requested = Event() query_changed = Event() result_selected = Event() load_requested = Event() def set_suggestion(self, suggestion): """Set the suggestions based on spelling. :param result: the encoded text :type result: :class:`str` """ raise NotImplementedError() def set_query_translation(self, query_translation): """Set the query text which has been translated to Entrez search terms. :param query_translation: the translated query :type query_translation: :class:`str` """ raise NotImplementedError() def set_seq_locus(self, locus, ncbi_url): """Set the selected sequence's locus and URL to access on NCBI. Basically, identify the sequence on NCBI. :param locus: sequence's locus :type locus: :class:`str` :param ncbi_url: URL to sequence on NCBI :type ncbi_url: :class:`str` """ raise NotImplementedError() def set_seq_desc(self, desc): """Set the selected sequence's description. :param desc: sequence's description :type desc: :class:`str` """ raise NotImplementedError() def set_seq_len(self, len_str): """Set the length of the sequence. :param len: sequence length as a string :type len: :class:`str` """ raise NotImplementedError() def set_selected_seq(self, seq_str): """Set the selected sequence. :param seq_str: the sequence data :type seq_str: :class:`str` """ raise NotImplementedError() def set_result(self, results): """Set the list of sequence ids. :param result: list of sequence ids :type result: :class:`list` """ raise NotImplementedError()