dereneaton / ipyrad

Interactive assembly and analysis of RAD-seq data sets
http://ipyrad.readthedocs.io
GNU General Public License v3.0
70 stars 39 forks source link

window_extracter: 'str' object has no attribute 'decode' #481

Closed alexkrohn closed 1 year ago

alexkrohn commented 2 years ago

This issue seems similar to #451, but since it's a different function, I figured I'd open another issue.

I'm trying to subset my phylip from ipyrad to include less missing data. Unfortunately, I can't import the *seqs.hdf5. The file is fresh from ipyrad, so it doesn't seem like it's an issue with the file, but it might be. I'm running ipyrad version 0.9.81.

Here's what I've tried:

import ipyrad.analysis as ipa

# Import seqs
seqfile = "sicklefin-mtgenome.seqs.hdf5"

# View scaffolds
ext = ipa.window_extracter(seqfile)

and the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/kk/scwljzqs5gb9zsd8m4rxwsbr0000gn/T/ipykernel_5892/4263024436.py in <module>
      3 
      4 # View scaffolds
----> 5 ext = ipa.window_extracter(seqfile)

~/miniconda3/envs/ipyrad/lib/python3.8/site-packages/ipyrad/analysis/window_extracter.py in __init__(self, data, name, workdir, scaffold_idxs, start, end, mincov, rmincov, exclude, imap, minmap, consensus_reduce, quiet, **kwargs)
    146 
    147         # gets .names, .pnames, .scaffold_table from the database file.
--> 148         self._parse_scaffolds()
    149 
    150         # if iterable of size 1 then extract single value. [1] -> 1

~/miniconda3/envs/ipyrad/lib/python3.8/site-packages/ipyrad/analysis/window_extracter.py in _parse_scaffolds(self)
    318 
    319             # get sample names
--> 320             self.pnames = np.array([
    321                 i.decode() for i in io5["phymap"].attrs["phynames"]
    322             ])

~/miniconda3/envs/ipyrad/lib/python3.8/site-packages/ipyrad/analysis/window_extracter.py in <listcomp>(.0)
    319             # get sample names
    320             self.pnames = np.array([
--> 321                 i.decode() for i in io5["phymap"].attrs["phynames"]
    322             ])
    323             self.allnames = [i.strip() for i in self.pnames]

AttributeError: 'str' object has no attribute 'decode'
alexkrohn commented 2 years ago

Alternatively, is there a better way to subset an ipyrad nexus or phylip file to keep sites present in x% of individuals, or all individuals with at least y% non-missing data?

isaacovercast commented 1 year ago

This is fixed, should have closed this when i fixed it.