nmdp-bioinformatics / py-gfe

Python package for creating GFE notation from annotated sequences
GNU General Public License v3.0
2 stars 9 forks source link

Documentation updates please #27

Open jbrelsf2-nmdp opened 5 years ago

jbrelsf2-nmdp commented 5 years ago

Using the docs: https://pygfe.readthedocs.io/en/latest/readme.html I'm unable to run through the example code.

Building and running in local python 3.7 env.

from Bio import SeqIO
from BioSQL import BioSeqDatabase
from seqann.sequence_annotation import BioSeqAnn
import pygfe
seq_file = 'DQB1_gen.fasta'
gfe = pygfe.pyGFE()
server = BioSeqDatabase.open_database(driver="pymysql", user="root", passwd="my-secret-pw", host="localhost", db="bioseqdb")
seqann = BioSeqAnn(server=server)
seq_rec = list(SeqIO.parse(seq_file, 'fasta'))[0]
annotation = seqann.annotate(seq_rec, "HLA-DQB1")
#gfe = gfe.gfe_create("HLA-DQB1", "DQB1_gen.fasta", '3220_DQB1')
gfe = gfe.sequence_lookup("HLA-DQB1", "DQB1_gen.fasta", '3220_DQB1')
print(gfe)

Error:

Traceback (most recent call last):
  File "run-sample.py", line 12, in <module>
    gfe = gfe.sequence_lookup("HLA-DQB1", "DQB1_gen.fasta", '3220_DQB1')
  File "/Users/jbrelsf2/Documents/sandbox/pyGFE/pygfe/pygfe.py", line 357, in sequence_lookup
    sequence_data = self.graph.run(lookup_query).to_data_frame()
AttributeError: 'NoneType' object has no attribute 'run'
mhalagan commented 5 years ago

It looks like that's an outdated example. The documentation for this package is pretty terrible. In order for this example to work, you need to initalize the pygfe class with a py2neo Graph object (ex. pygfe.pyGFE(graph=graph)). If you initialize BioSeqAnnwith a server, then you need to make sure that server is running locally.