Skip to content

Commit

Permalink
2.6.5
Browse files Browse the repository at this point in the history
Releases from this point forward will only fix bugs, no new features will be added
on the 2.x branch. Please prepare to migrate your code to the 3.x branch once you
are running in a Python3 environment.

Changes:

    Fix a bug in normalize() which sorted loop and saveframe tags according to the default schema
    rather than provided schema.
    Added DeprecationWarning to methods and functions that are removed in v3.x releases or will
    be removed in the future.
    Fix a bug in Loop.filter() triggered when a loop only has one tag.
  • Loading branch information
jonwedell authored Dec 9, 2019
2 parents a3639d2 + 76ec3ae commit 16f93e6
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 77 deletions.
Empty file added .nocompile
Empty file.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "nightly"
# command to run tests
script: touch ".nocompile" && ./pynmrstar.py && rm .nocompile && ./pynmrstar.py
script: touch ".nocompile" && ./unit_tests/bmrb_test.py && rm .nocompile && ./unit_tests/bmrb_test.py
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PyNMRSTAR was created by Jon Wedell <[email protected]> in
2014.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# PyNMRSTAR
A Python module for reading, writing, and manipulating NMR-STAR files. [![BuildStatus](https://travis-ci.org/uwbmrb/PyNMRSTAR.svg?branch=v2)](https://travis-ci.org/uwbmrb/PyNMRSTAR)

Python versions supported: 2.6, 2.7, 3.3, 3.4, 3.5, and 3.6
Python versions officially supported: 2.7, 3.4, 3.5, 3.6, 3.7, 3.8
Python versions that are not tested but should work: 2.6, 3.3

## Overview

Expand All @@ -14,7 +15,7 @@ Finally, there are several command-line based tools developed to enable simple q

To understand how the library works, you first need to understand the NMR-STAR terminology and file format. If you are already familiar with NMR-STAR, feel free to [jump ahead](#quick-start-to-pynmrstar) to the section on this library.

A NMR-STAR entry/file is componsed of one or more saveframes (conceptually you should think of a saveframe as a data block), each of which contain tags and loops. There can only be one of each tag in a saveframe. If a tag has multiple values, the only way to represent it is to place it inside a loop. A loop is simply a set of tags with multiple values.
A NMR-STAR entry/file is composed of one or more saveframes (conceptually you should think of a saveframe as a data block), each of which contain tags and loops. There can only be one of each tag in a saveframe. If a tag has multiple values, the only way to represent it is to place it inside a loop. A loop is simply a set of tags with multiple values.

Therefore, hierarchically, you can picture a NMR-STAR file as a tree where the entry is the trunk, the large branches are the saveframes, and each saveframe may contain one or more loops - the branches.

Expand Down Expand Up @@ -149,7 +150,7 @@ You can access the saveframes in an entry directly using their *names*. For exam
```
Note that you can see the saveframe names in the tree printout above.

You can do the same for loops within a saveframe, but for loops you must use their tag category (the part before the period) to access them (note that to get to the `Vendor` loop we first had to go through its parent saveframe, named `X-PLOR_NIH` (the `X-PLOR_NIH` saveframe is of the category `software` - you'll see where you access the category later and why accessing by category is preferrable).
You can do the same for loops within a saveframe, but for loops you must use their tag category (the part before the period) to access them (note that to get to the `Vendor` loop we first had to go through its parent saveframe, named `X-PLOR_NIH` (the `X-PLOR_NIH` saveframe is of the category `software` - you'll see where you access the category later and why accessing by category is preferable).
```python
>>> explor_nih_vendor = entry15000['X-PLOR_NIH']['_Vendor']
>>> print explor_nih_vendor
Expand Down Expand Up @@ -235,7 +236,7 @@ The following will combine all the task loops in the entry into CSV format.
>>> csv_data = ""
>>> for software_sf in software_saveframes:
>>> print_header = True
>>> # Wrap this in try/catch because it is not gauranteed a software saveframe will have a task loop
>>> # Wrap this in try/catch because it is not guaranteed a software saveframe will have a task loop
>>> try:
>>> csv_data += software_sf['_Task'].get_data_as_csv(header=print_header)
>>> print_header = False
Expand Down Expand Up @@ -285,7 +286,7 @@ To view all of the tags in the NMR-STAR schema and their meanings, please go [he

*"I just want to get the chemical shift data as an array - how do I do that?"*

Keep in mind that an entry may have multiple sets of assigned chemical shifts. (For examples, there made be two sets of assignments that were made under two differerent sample conditions.) So to get the chemical shifts it is best to iterate through all the assigned chemical shift loops:
Keep in mind that an entry may have multiple sets of assigned chemical shifts. (For examples, there may be two sets of assignments that were made under two different sample conditions.) So to get the chemical shifts it is best to iterate through all the assigned chemical shift loops:

```python
>>> cs_result_sets = []
Expand Down Expand Up @@ -374,7 +375,7 @@ This tutorial has so far focused on how to read and access data. This section wi

## Loops

There are five ways to make a new loop: `from_file()`, `from_json()`, `from_scratch()`, `from_string()`, and `from_template()`. All of these are classmethods. `from_scratch()` makes a new loop, `from_string()` parses an NMR-STAR loop from a python string containing NMR-STAR data, `from_json()` parses a JSON object (reversely, `get_json()` will get a JSON representation of the loop), `from_scratch()` makes a completely empty loop, and `from_template()` makes a loop with the tags prefilled from the BMRB schema based on the provided category. `from_file`, `from_json`, and `from_string` are fairly self-explanatory - see the full documentation if needed for usage.
There are five ways to make a new loop: `from_file()`, `from_json()`, `from_scratch()`, `from_string()`, and `from_template()`. All of these are classmethods. `from_scratch()` makes a new loop, `from_string()` parses an NMR-STAR loop from a python string containing NMR-STAR data, `from_json()` parses a JSON object (reversely, `get_json()` will get a JSON representation of the loop), `from_scratch()` makes a completely empty loop, and `from_template()` makes a loop with the tags pre-filled from the BMRB schema based on the provided category. `from_file`, `from_json`, and `from_string` are fairly self-explanatory - see the full documentation if needed for usage.

#### `from_scratch()`

Expand Down Expand Up @@ -465,7 +466,7 @@ This method will create a new loop ready for data with the tags from the BMRB sc

## Saveframes

There are five ways to make a new loop: `from_file()`, `from_json()`, `from_scratch()`, `from_string()`, and `from_template()`. All of these are classmethods. `from_scratch()` makes a new saveframe, `from_string()` parses an NMR-STAR saveframe from a python string containing NMR-STAR data, `from_json()` parses a JSON object (reversely, `get_json()` will get a JSON representation of the saveframe), `from_scratch()` makes a completely empty saveframe, and `from_template()` makes a saveframe with the tags prefilled from the BMRB schema based on the provided category. `from_file`, `from_json`, and `from_string` are fairly self-explanatory - see the full documentation if needed for usage.
There are five ways to make a new loop: `from_file()`, `from_json()`, `from_scratch()`, `from_string()`, and `from_template()`. All of these are classmethods. `from_scratch()` makes a new saveframe, `from_string()` parses an NMR-STAR saveframe from a python string containing NMR-STAR data, `from_json()` parses a JSON object (reversely, `get_json()` will get a JSON representation of the saveframe), `from_scratch()` makes a completely empty saveframe, and `from_template()` makes a saveframe with the tags pre-filled from the BMRB schema based on the provided category. `from_file`, `from_json`, and `from_string` are fairly self-explanatory - see the full documentation if needed for usage.

#### `from_scratch()`
```python
Expand Down
1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

20 changes: 20 additions & 0 deletions do_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

while true; do
read -p "Have you updated the version number in bmrb.py? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done

while true; do
read -p "Do release or test? " rt
case $rt in
[Rr]* ) python3 -m twine upload dist/*.tar.gz --sign; rm -rfv pynmrstar pynmrstar.egg-info; break;;
[Tt]* ) mkdir pynmrstar; cp bmrb.py pynmrstar/__init__.py; cp -rv reference_files pynmrstar; touch pynmrstar/.nocompile; cp README.md pynmrstar; python3 setup.py sdist; rm -rfv pynmrstar pynmrstar.egg-info; break;;
* ) echo "Please answer r or t.";;
esac
done

Loading

0 comments on commit 16f93e6

Please sign in to comment.