Code Monkey home page Code Monkey logo

Comments (8)

dennisbrookner avatar dennisbrookner commented on June 12, 2024 2

Just created a fresh conda environment with rs 0.9.3, and it works now. Not sure if the fresh environment or the update is what fixed it, but in either case, thanks!

from reciprocalspaceship.

JBGreisman avatar JBGreisman commented on June 12, 2024 1

This seems likely to be a local environment issue, but I pushed a new PyPI release (0.9.3) so that all of the examples are consistent with the latest version available through pip install

from reciprocalspaceship.

JBGreisman avatar JBGreisman commented on June 12, 2024

Based on the error traceback, it appears that the spacegroup attribute was not set when you loaded HEWL_unmerged.mtz. That is certainly strange, but do you mind confirming the hewl DataSet instance has all the expected fields?

Regarding the second part, rs.algorithms.merge() was added relatively recently and I haven't yet made an official PyPI release. I will do so shortly.

from reciprocalspaceship.

JBGreisman avatar JBGreisman commented on June 12, 2024

I'm not quite able to reproduce the error locally with regard to the HEWL_unmerged.mtz:

> pwd
/Users/jgreisman/Documents/Hekstra_Lab/github/reciprocalspaceship/docs/examples

> rs.mtzdump  data/HEWL_unmerged.mtz --embed
Spacegroup: P43212
Extended Hermann-Mauguin name: P 43 21 2
Unit cell dimensions: 79.344 79.344 37.810 90.000 90.000 90.000

mtz.head():

       BATCH         I      SIGI  PARTIAL
H K L                                    
0 0 4    137  696.5212  87.83294    False
    4    520  710.6812 88.107025    False
    4    856 672.05634  87.75671    False
    4   1239 642.47485  87.90302    False
    4   2160 655.71783  87.74394    False

mtz.describe():

            BATCH           I        SIGI
count  816804.000  816804.000  816804.000
mean     1720.375     606.572      82.154
std      1082.828     829.815     106.452
min         1.000     -12.324       0.192
25%       720.000      85.008      14.543
50%      2001.000     275.463      38.605
75%      2720.000     777.393     104.605
max      3439.000    9844.659     783.325

mtz.dtypes:

BATCH          Batch
I          Intensity
SIGI          Stddev
PARTIAL         bool
dtype: object

Python 3.8.5 (default, Sep  4 2020, 02:22:02) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.


rs.DataSet stored as mtz

In [1]: rs.algorithms.merge(mtz)
Out[1]: 
             IMEAN   SIGIMEAN      I(+)    SIGI(+)      I(-)    SIGI(-)  N(+)  N(-)
H  K  L                                                                            
0  0  4  661.29987  21.953098 661.29987  21.953098 661.29987  21.953098    16    16
      8  3229.6492 105.980934 3229.6492 105.980934 3229.6492 105.980934    16    16
      12 1361.8672   43.06085 1361.8672   43.06085 1361.8672   43.06085    16    16
      16  4124.393  196.89108  4124.393  196.89108  4124.393  196.89108     8     8
1  0  1   559.3369   8.626299  559.3369   8.626299  559.3369   8.626299    64    64
...            ...        ...       ...        ...       ...        ...   ...   ...
14 11 20   35.6825   8.251703       NaN        NaN   35.6825   8.251703     0     2
   10 20 52.386147  10.075351       NaN        NaN 52.386147  10.075351     0     2
   9  20 122.96966  13.823673       NaN        NaN 122.96966  13.823673     0     3
   8  20 149.46716  13.995815       NaN        NaN 149.46716  13.995815     0     4
11 7  20 25.917196   8.322451       NaN        NaN 25.917196   8.322451     0     2

[12542 rows x 8 columns]


from reciprocalspaceship.

dennisbrookner avatar dennisbrookner commented on June 12, 2024

Both in jupyter and in terminal/IPython, the dataset does appear to have space group assigned. Here's what I just did, analogous to your example:

> pwd
/Users/dennisbrookner/crystallography/reciprocalspaceship/docs/examples
> rs.mtzdump data/HEWL_unmerged.mtz --embed
Spacegroup: P43212
Extended Hermann-Mauguin name: P 43 21 2
Unit cell dimensions: 79.344 79.344 37.810 90.000 90.000 90.000

mtz.head():

       BATCH         I      SIGI  PARTIAL
H K L                                    
0 0 4    137  696.5212  87.83294    False
    4    520  710.6812 88.107025    False
    4    856 672.05634  87.75671    False
    4   1239 642.47485  87.90302    False
    4   2160 655.71783  87.74394    False

mtz.describe():

            BATCH           I        SIGI
count  816804.000  816804.000  816804.000
mean     1720.375     606.572      82.154
std      1082.828     829.815     106.452
min         1.000     -12.324       0.192
25%       720.000      85.008      14.543
50%      2001.000     275.463      38.605
75%      2720.000     777.393     104.605
max      3439.000    9844.659     783.325

mtz.dtypes:

BATCH          Batch
I          Intensity
SIGI          Stddev
PARTIAL         bool
dtype: object

Python 3.8.5 | packaged by conda-forge | (default, Jul 31 2020, 02:18:36) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.


rs.DataSet stored as mtz

In [1]: rs.algorithms.merge(mtz)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/commandline/mtzdump.py in <module>
----> 1 rs.algorithms.merge(mtz)

~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/algorithms/merge.py in merge(dataset, intensity_key, sigma_key, sort)
     38 
     39     # Reshape anomalous data and use to compute IMEAN / SIGIMEAN
---> 40     result = result.unstack_anomalous()
     41     result.loc[:, ["N(+)", "N(-)"]] = result[["N(+)", "N(-)"]].fillna(0).astype("I")
     42     result["IMEAN"] = result[["wI(+)", "wI(-)"]].sum(axis=1) / result[["w(+)", "w(-)"]].sum(axis=1).astype("Intensity")

~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/dataset.py in wrapped(ds, *args, **kwargs)
     56         names = ds.index.names
     57         ds = ds._index_from_names([None], inplace=True)
---> 58         result = f(ds, *args, **kwargs)
     59         result = result._index_from_names(names, inplace=True)
     60         ds = ds._index_from_names(names, inplace=True)

~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/dataset.py in unstack_anomalous(self, columns, suffixes)
    876         # Separate DataSet into Friedel(+) and Friedel(-)
    877         columns = set(columns).union(set(["H", "K", "L"]))
--> 878         dataset = self.hkl_to_asu()
    879         if "PARTIAL" in columns: columns.remove("PARTIAL")
    880         for column in columns:

~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/dataset.py in wrapped(ds, *args, **kwargs)
     37                 return f(ds, *args, **kwargs)
     38             else:
---> 39                 return f(ds.copy(), *args, **kwargs)
     40         else:
     41             raise KeyError(f'"inplace" not found in local variables of @inplacemethod decorated function {f} '

~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/dataset.py in wrapped(ds, *args, **kwargs)
     56         names = ds.index.names
     57         ds = ds._index_from_names([None], inplace=True)
---> 58         result = f(ds, *args, **kwargs)
     59         result = result._index_from_names(names, inplace=True)
     60         ds = ds._index_from_names(names, inplace=True)

~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/dataset.py in hkl_to_asu(self, inplace, anomalous)
    975         hkls = dataset.get_hkls()
    976         compressed_hkls, inverse = np.unique(hkls, axis=0, return_inverse=True)
--> 977         asu_hkls, isym, phi_coeff, phi_shift = hkl_to_asu(
    978             compressed_hkls,
    979             dataset.spacegroup,

~/miniconda3/envs/rs/lib/python3.8/site-packages/reciprocalspaceship-0.9.2-py3.8.egg/reciprocalspaceship/utils/asu.py in hkl_to_asu(H, spacegroup, return_phase_shifts)
     82         an array length n containing phase shifts in degrees
     83     """
---> 84     basis_op = spacegroup.basisop
     85     group_ops = spacegroup.operations()
     86     num_ops = len(group_ops)

AttributeError: 'NoneType' object has no attribute 'basisop'

In [2]: mtz.spacegroup
Out[2]: <gemmi.SpaceGroup("P 43 21 2")>

from reciprocalspaceship.

JBGreisman avatar JBGreisman commented on June 12, 2024

What's your pandas version?

from reciprocalspaceship.

dennisbrookner avatar dennisbrookner commented on June 12, 2024

I have pandas 1.1.0. I'll uninstall and re-pip install, and see if that fixes it.

from reciprocalspaceship.

JBGreisman avatar JBGreisman commented on June 12, 2024

Let me know if that works -- depending on the situation in that environment it also may be worth starting from a clean conda environment. That will at least make it easier for me to reproduce any issues on my end.

from reciprocalspaceship.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.