class documentation

SSH-based file reader that extends FileReader to handle file operations over SSH/SFTP. Enables reading, writing, listing, and transferring files on a remote server securely.

Method __del__ Destructor that closes SSH and SFTP connections and cleans up resources.
Method __init__ Initialize SSH and SFTP connection parameters.
Method download_remote_file Download a remote file via SFTP.
Method filter_output Filter SSH command output using predefined patterns.
Method get_file_size Get the size of a file on the remote server.
Method isfile Check whether the given remote path points to a file.
Method listdir List files and directories at a remote path.
Method load_h5ad_file Download an h5ad file from the remote server in chunks.
Method run_cmd Run a command on the remote server via SSH.
Method write_to_remote_file Write data (string or DataFrame) to a file on the remote server.
Instance Variable filter_file Undocumented
Instance Variable filtered_patterns Undocumented
Instance Variable password Undocumented
Instance Variable port Undocumented
Instance Variable remote Undocumented
Instance Variable server Undocumented
Instance Variable sftp Undocumented
Instance Variable sftp_client Undocumented
Instance Variable sftp_ssh_client Undocumented
Instance Variable ssh_client Undocumented
Instance Variable username Undocumented
Method _connect Establish SSH and SFTP connections using Paramiko.
Method _create_ssh_client Undocumented
Method _load_filtered_patterns Load SSH output filter patterns from YAML configuration.
Method _read_file_content Undocumented
Method _read_vcf_as_dataframe Undocumented

Inherited from FileReader:

Method clean_tmp_files Deletes a temporary file if it exists.
Method decode_content_by_type Decodes content based on file type, returning a DataFrame or raw string.
Method get_file_extension Extracts the file extension from a given path.
Method is_remote Checks if the reader is set to remote mode.
Method read_file Unified file reader for local or remote paths. :param path: File path. :param type: Optional file type override (generic types: pdf, image, text, csv, zip). :param as_dataframe: Whether to parse into a DataFrame...
Method read_file_into_df File reader into a dataframe for local and remote paths :param path: File path. :param type: Optional file type override (generic types: pdf, image, text, csv, zip). :param as_dataframe: Force a parsing into a DataFrame...
Method read_h5ad Reads an H5AD file using `anndatareader`.
Method read_vcf_file_into_df Reads a VCF (Variant Call Format) file using `pysam`.
Method set_clean_on_dest Sets the `clean_on_destruction` flag.
Instance Variable clean_on_destruction Undocumented
Instance Variable files_to_clean Undocumented
Method _is_auto_dataframe_type Undocumented
Method _is_binary_type Undocumented
Method _is_text_type Undocumented
def __del__(self):

Destructor that closes SSH and SFTP connections and cleans up resources.

def __init__(self, server='alma.icr.ac.uk', username=None, password=None, sftp='alma-app.icr.ac.uk', port=22):

Initialize SSH and SFTP connection parameters.

:param server: Main SSH server address. :type server: str :param username: SSH username. :type username: str :param password: SSH password. :type password: str :param sftp: SFTP host (defaults to `server` if not specified). :type sftp: str

def download_remote_file(self, remote_path, local_path):

Download a remote file via SFTP.

:param remote_path: Path on the remote server. :type remote_path: str :param local_path: Local destination path. :type local_path: str

def filter_output(self, output):

Filter SSH command output using predefined patterns.

:param output: Raw output from SSH command. :type output: str :return: Filtered output string. :rtype: str

def get_file_size(self, path):

Get the size of a file on the remote server.

:param path: Remote file path. :type path: str :return: Size in bytes, or None if error. :rtype: int | None

def isfile(self, path):

Check whether the given remote path points to a file.

:param path: Remote path. :type path: str :return: True if path is a file. :rtype: bool

def listdir(self, path):

List files and directories at a remote path.

:param path: Remote directory path. :type path: str :return: Tuple of (directories, files). :rtype: tuple[list[str], list[str]]

def load_h5ad_file(self, path, local_path):

Download an h5ad file from the remote server in chunks.

:param path: Remote file path. :type path: str :param local_path: Destination on local machine. :type local_path: str :return: Local path of the saved file or None if failed. :rtype: str | None

def run_cmd(self, command):

Run a command on the remote server via SSH.

:param command: Command to execute. :type command: str :return: Dictionary with 'output' and 'err' keys. :rtype: dict

def write_to_remote_file(self, data, remote_path, file_format='csv'):

Write data (string or DataFrame) to a file on the remote server.

:param data: The data to write. :type data: pd.DataFrame | str :param remote_path: Destination path on the remote server. :type remote_path: str :param file_format: Format to use ('csv' supported for DataFrames). :type file_format: str :raises ValueError: If unsupported DataFrame format is specified. :raises TypeError: If data is not string or DataFrame.

filter_file =

Undocumented

filtered_patterns =

Undocumented

password =

Undocumented

port =

Undocumented

remote: bool =

Undocumented

server =

Undocumented

sftp =

Undocumented

sftp_client =

Undocumented

sftp_ssh_client =

Undocumented

ssh_client =

Undocumented

username =

Undocumented

def _connect(self):

Establish SSH and SFTP connections using Paramiko.

:raises ConnectionError: If authentication or connection fails.

def _create_ssh_client(self):

Undocumented

def _load_filtered_patterns(self):

Load SSH output filter patterns from YAML configuration.

:return: Filter configuration dictionary. :rtype: dict

def _read_file_content(self, path, mode, is_text):

Undocumented

def _read_vcf_as_dataframe(self, path):

Undocumented