Searching for Rosetta Binaries.
Project description
RosettaFinder
A Python utility for finding Rosetta binaries based on a specific naming convention.
CI Status
Release
Python version supported
Overview
RosettaFinder
is a Python module designed to locate Rosetta biomolecular modeling suite binaries that follow a specific naming pattern. It searches predefined directories and can handle custom search paths. The module includes:
- An object-oriented
RosettaFinder
class to search for binaries. - A
RosettaBinary
dataclass to represent the binary and its attributes. - A command-line shortcut for quick access to Rosetta binaries.
- Unit tests to ensure reliability and correctness.
Features
- Flexible Binary Search: Finds Rosetta binaries based on their naming convention.
- Platform Support: Supports Linux and macOS operating systems.
- Customizable Search Paths: Allows specification of custom directories to search.
- Structured Binary Representation: Uses a dataclass to encapsulate binary attributes.
- Command-Line Shortcut: Provides a quick way to find binaries via the command line.
- Available on PyPI: Installable via
pip
without the need to clone the repository. - Unit Tested: Includes tests for both classes to ensure functionality.
Naming Convention
The binaries are expected to follow this naming pattern:
rosetta_scripts[.mode].oscompilerrelease
- Binary Name:
rosetta_scripts
(default) or specified. - Mode (optional):
default
,mpi
, orstatic
. - OS:
linux
ormacos
. - Compiler:
gcc
orclang
. - Release:
release
ordebug
.
Examples of valid binary filenames:
rosetta_scripts.linuxgccrelease
rosetta_scripts.mpi.macosclangdebug
rosetta_scripts.static.linuxgccrelease
Installation
Ensure you have Python 3.6 or higher installed.
Install via PyPI
You can install RosettaPy
directly from PyPI:
pip install RosettaPy -U
This allows you to use RosettaPy
without cloning the repository.
Usage
Command-Line Shortcut
RosettaPy
provides a command-line shortcut to quickly locate Rosetta binaries.
Using the whichrosetta
Command
After installing RosettaPy
, you can use the whichrosetta
command in your terminal.
whichrosetta <binary_name>
Example:
To find the relax
binary:
relax_bin=$(whichrosetta relax)
echo $relax_bin
This command assigns the full path of the relax
binary to the relax_bin
variable and prints it.
Importing the Module
You can also use RosettaPy
in your Python scripts.
from RosettaPy import RosettaFinder, RosettaBinary
Finding a Rosetta Binary in Python
# Initialize the finder (optional custom search path)
finder = RosettaFinder(search_path='/custom/path/to/rosetta/bin')
# Find the binary (default is 'rosetta_scripts')
rosetta_binary = finder.find_binary('rosetta_scripts')
# Access binary attributes
print(f"Binary Name: {rosetta_binary.binary_name}")
print(f"Mode: {rosetta_binary.mode}")
print(f"OS: {rosetta_binary.os}")
print(f"Compiler: {rosetta_binary.compiler}")
print(f"Release: {rosetta_binary.release}")
print(f"Full Path: {rosetta_binary.full_path}")
Example Output
Binary Name: rosetta_scripts
Mode: mpi
OS: linux
Compiler: gcc
Release: release
Full Path: /custom/path/to/rosetta/bin/rosetta_scripts.mpi.linuxgccrelease
Environment Variables
The RosettaFinder
searches the following directories by default:
- The path specified in the
ROSETTA_BIN
environment variable. ROSETTA3/bin
ROSETTA/main/source/bin/
- A custom search path provided during initialization.
Set the ROSETTA_BIN
environment variable to include your custom binary directory:
export ROSETTA_BIN=/path/to/your/rosetta/bin
API Reference
whichrosetta
Command
The whichrosetta
command is installed as part of the RosettaPy
package and allows you to find the path to a Rosetta binary from the command line.
Usage:
whichrosetta <binary_name>
binary_name
: The name of the Rosetta binary you want to locate (e.g.,relax
,rosetta_scripts
).
Example:
relax_bin=$(whichrosetta relax)
echo $relax_bin
This command finds the relax
binary and prints its full path.
RosettaFinder
Class
-
Initialization
RosettaFinder(search_path=None)
search_path
(optional): A custom directory to include in the search paths.
-
Methods
-
find_binary(binary_name='rosetta_scripts')
Searches for the specified binary and returns a
RosettaBinary
instance.-
binary_name
(optional): Name of the binary to search for. -
Raises:
FileNotFoundError
: If the binary is not found.EnvironmentError
: If the OS is not Linux or macOS.
-
-
RosettaBinary
Dataclass
-
Attributes
dirname
: Directory where the binary is located.binary_name
: Base name of the binary.mode
: Build mode (static
,mpi
,default
, orNone
).os
: Operating system (linux
ormacos
).compiler
: Compiler used (gcc
orclang
).release
: Build type (release
ordebug
).
-
Properties
filename
: Reconstructed filename based on the attributes.full_path
: Full path to the binary executable.
-
Class Methods
-
from_filename(dirname: str, filename: str)
Creates an instance by parsing the filename.
- Raises:
ValueError
: If the filename does not match the expected pattern.
- Raises:
-
Running Tests
The project includes unit tests using Python's unittest
framework.
Running Tests
-
Clone the repository (if not already done):
git clone https://github.com/yourusername/RosettaPy.git cd RosettaPy
-
Navigate to the project directory:
cd RosettaPy
-
Run the tests:
python -m unittest discover tests
Test Coverage
The tests cover:
- Parsing valid and invalid filenames with
RosettaBinary
. - Finding binaries with
RosettaFinder
, including scenarios where binaries are found or not found. - OS compatibility checks.
Contributing
Contributions are welcome! Please submit a pull request or open an issue for bug reports and feature requests.
License
This project is licensed under the MIT License.
Acknowledgements
- Rosetta Commons: The Rosetta software suite for the computational modeling and analysis of protein structures.
Contact
For questions or support, please contact:
- Name: Yinying Yao
- Email:yaoyy.hi(a)gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rosettapy-0.1.0rc108.post1.tar.gz
.
File metadata
- Download URL: rosettapy-0.1.0rc108.post1.tar.gz
- Upload date:
- Size: 314.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae95bb89b58650334a0c255c5bf731a00bf384cc2660a7963fcbbf4790ffc382 |
|
MD5 | 25ae2b7b4d0f48fbcff2abcc00405869 |
|
BLAKE2b-256 | 2b44c8514cfced7cbf76e364b1527d1dc40915ac4ec319a9182e9f3a38e9d307 |
File details
Details for the file rosettapy-0.1.0rc108.post1-py3-none-any.whl
.
File metadata
- Download URL: rosettapy-0.1.0rc108.post1-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 052350e372cb0349dc7df15587c9af443126082d870cfa4d0c38f9b4e46c4790 |
|
MD5 | 1d3086b665d310ef637637f5c0903c2d |
|
BLAKE2b-256 | 9c9192d22256fea311e5fccc520ca7a8ce87167e484c2da5da4c726c145101ca |