Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
Build Binary and fix docs (#10)
Browse files Browse the repository at this point in the history
* add main.rs and CLAP parser to create a binary

* rename

* update docs by fixing the redirect
  • Loading branch information
zachcp authored Jul 20, 2024
1 parent 48c0405 commit 9646aa9
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Docs
on:
push:
branches: [main]
branches: [main, 20240719-view]
permissions:
contents: read
pages: write
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Build docs
run: cargo doc --no-deps
- name: Add redirect
run: echo '<meta http-equiv="refresh" content="0;url=aoc/index.html">' > target/doc/index.html
run: echo '<meta http-equiv="refresh" content="0;url=pseutils/index.html">' > target/doc/index.html
- name: Remove lock file
run: rm target/doc/.lock
- name: Upload artifact
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
/binary_test
/test_temporary
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "pymol_session_utils"
name = "pseutils"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = { version = "4.5.9", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde-pickle = "1.1"
Expand All @@ -13,6 +14,4 @@ validator = { version = "0.18", features = ["derive"] }
pdbtbx = "0.11.0"
itertools = "0.13.0"
urlencoding = "2.1.3"
num-traits = "0.2"
num-derive = "0.3"
serde_repr = "0.1.19"
19 changes: 18 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pymol_session_utils

**WIP: Currently not working**
**Note: Work In Progress. Feature Incomplete**


## Goal
Expand All @@ -21,6 +21,23 @@ cargo clean --doc && cargo doc --no-deps --open
# to look at results
cargo test # generate an example
cd test_temporary && python -m http.server

# build the binary and test
cargo build --release
./target/release/pseutils --psefile tests/data/example.pse --outputdir binary_test

# outputs a complete directory
> tree binary_test
binary_test
├── index.html
├── molstar.css
├── molstar.js
├── pdb
│   └── 1pdb.pdb
├── pdb_contents.txt
└── state.mvsj


```

## Status
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
//!
//! it is currently a work in progress.
//!
#[macro_use]
extern crate num_derive;

pub mod molviewspec;
pub mod pymolparsing;

Expand Down
24 changes: 24 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use clap::Parser;
use pseutils::pymolparsing::psedata::PSEData;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Path to the PSE file
#[arg(short, long)]
psefile: String,

/// Output directory
#[arg(short, long)]
outputdir: String,
}

fn main() {
let args = Args::parse();

println!("PSE file: {}", args.psefile);
println!("Output directory: {}", args.outputdir);

let psedata: PSEData = PSEData::load(&args.psefile).expect("Reachable PSE file");
let _ = psedata.to_disk_full(&args.outputdir);
}
3 changes: 0 additions & 3 deletions src/pymolparsing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
// it may be advisable down the line to split these out
pub mod parsing;
pub mod psedata;
pub mod settings;

use crate::molviewspec;
6 changes: 3 additions & 3 deletions src/pymolparsing/psedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

use crate::molviewspec::nodes::{self as mvsnodes, CameraParams, ColorNamesT, State};
use crate::pymolparsing::parsing::{
CustomValue, PyObjectMolecule, PymolSessionObjectData, SceneView, SessionName,
SessionSelectorList, Settings, SettingsEnum,
PyObjectMolecule, PymolSessionObjectData, SceneView, SessionName, SessionSelectorList,
Settings, SettingsEnum,
};
use pdbtbx::PDB;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -161,7 +161,7 @@ impl PSEData {
let pdb_folder = path.join("pdb");
std::fs::create_dir_all(&pdb_folder)?;
let mut file_list = Vec::new();
for (index, molecule) in self.get_molecule_data().iter().enumerate() {
for molecule in self.get_molecule_data().iter() {
let pdb = molecule.to_pdb();
let filename = format!("{}.pdb", molecule.get_name());
let file_path = pdb_folder.join(&filename);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pse_parsing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pymol_session_utils::pymolparsing::parsing::{CustomValue, Settings, SettingsEnum};
use pymol_session_utils::pymolparsing::parsing::{CustomValue, SettingsEnum};
use pymol_session_utils::PSEData;
const TEST_OUTPUT_DIR: &str = "./test_temporary";

Expand Down

0 comments on commit 9646aa9

Please sign in to comment.