Skip to content

Numpy import error  #1

@ranijames

Description

@ranijames

Hi All,
I am trying to extract features from a given fasta file (DNA or RNA), using kmer.py script as per the description in the README. While running the code in a juypter notebook it is throwing the following error.

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-11-1066287f4a62> in <module>
      4 
      5 k   = 6  # choose the value for k
----> 6 obj = kmer_featurization(k)
      7 kmer_features = obj.obtain_kmer_feature_for_a_list_of_sequences(seq_list, write_number_of_occurrences=False)

~/Documents/lncRNAs_project_2020/scripts_2021/kmer/kmer.py in __init__(self, k)
      8     """
      9     self.k = k
---> 10     self.letters = ['A', 'T', 'C', 'G']
     11     self.multiplyBy = 4 ** np.arange(k-1, -1, -1) # the multiplying number for each digit position in the k-number system
     12     self.n = 4**k # number of possible k-mers

NameError: name 'np' is not defined

I am running the script in python 3.2.7, and I have numpy installed.
This is how I tried running the script,

from kmer import kmer_featurization 
import numpy as np
seq_list = ['ATCGA', 'TCGAC']  # a list of DNA sequences

k   = 6  # choose the value for k
obj = kmer_featurization(k) 
kmer_features = obj.obtain_kmer_feature_for_a_list_of_sequences(seq_list, write_number_of_occurrences=False)

Any suggestions/help is much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions