sivarajankumar / pygr

Automatically exported from code.google.com/p/pygr
0 stars 0 forks source link

schema binding gives an integer key error #116

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. create directory "ucsc1"
2. get refGene.txt.gz at 
http://hgdownload.cse.ucsc.edu/goldenPath/hg18/database/ and save 
into "ucsc1"
3. modify hg18 SequenceFileDB path in make_test.py (attached script)
4. run make_test.py in current directory (not "ucsc1" directory)

As far as I know, if we call attribute bound to SequenceFileDB (slice1.tu, 
bindAttrs = ('tu',)), it will 
retrieve all annotations. it gives integer key error.

>>> import os
>>> os.environ['WORLDBASEPATH'] = '.'
>>> from pygr import worldbase
>>> worldbase.dir()
['0root', '0version', 'Bio.Annotation.UCSC.refGene.HUMAN.hg18.tus', 
'Bio.MSA.UCSC.refGene.HUMAN.hg18.tus', 'Bio.Seq.Genome.HUMAN.hg18', 
'SCHEMA.Bio.Annotation.UCSC.refGene.HUMAN.hg18.tus', 
'SCHEMA.Bio.Seq.Genome.HUMAN.hg18', 
'__doc__.Bio.Annotation.UCSC.refGene.HUMAN.hg18.tus', 
'__doc__.Bio.MSA.UCSC.refGene.HUMAN.hg18.tus', 
'__doc__.Bio.Seq.Genome.HUMAN.hg18']
>>> hg18 = worldbase.Bio.Seq.Genome.HUMAN.hg18()
>>> tus = worldbase.Bio.Annotation.UCSC.refGene.HUMAN.hg18.tus()
>>> msa = worldbase.Bio.MSA.UCSC.refGene.HUMAN.hg18.tus()
>>> slice1 = hg18['chrY'][:500000]
>>> edges = msa[slice1].edges()
>>> len(edges)
4
>>> edges
[(chrY[138060:160020], annot31862[0:21960], <pygr.sequence.Seq2SeqEdge object 
at 
0x9ec4d0>), (chrY[161425:170887], -annot16267[0:9462], 
<pygr.sequence.Seq2SeqEdge 
object at 0x9ec750>), (chrY[214969:222590], -annot2893[0:7621], 
<pygr.sequence.Seq2SeqEdge object at 0x9ec810>), (chrY[214969:267627], -
annot3680[0:52658], <pygr.sequence.Seq2SeqEdge object at 0x9ec850>)]
>>> tus[31862]
annot31862[0:21960]
>>> slice1.tu
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/server/pygr/build/lib.linux-x86_64-2.5/pygr/metabase.py", line 61, in __get__
    result=targetDict[obj] # NOW PERFORM MAPPING IN THAT RESOURCE...
  File "/data/server/pygr/build/lib.linux-x86_64-2.5/pygr/annotation.py", line 167, in 
__getitem__
    return self.sliceAnnotation(k,self.sliceDB[k])
  File "/data/server/pygr/build/lib.linux-x86_64-2.5/pygr/mapping.py", line 395, in __getitem__
    return self.d[self.saveKey(k)]
  File "/data/server/pygr/build/lib.linux-x86_64-2.5/pygr/mapping.py", line 387, in saveKey
    raise KeyError('IntShelve can only save int or str as key')
KeyError: 'IntShelve can only save int or str as key'
>>> 

Original issue reported on code.google.com by deepr...@gmail.com on 7 Sep 2009 at 1:21

Attachments:

GoogleCodeExporter commented 8 years ago
Namshin,
I think this script make_test.py has a bug: it tags the AnnotationDB, not the 
NLMSA,
as being a ManyToManyRelation.  That is incorrect.  Instead of this line:
mdb.add_schema('Bio.Annotation.UCSC.refGene.HUMAN.hg18.tus', tu_schema)

it should instead be:
mdb.add_schema('Bio.MSA.UCSC.refGene.HUMAN.hg18.tus', tu_schema)

Original comment by cjlee...@gmail.com on 10 Sep 2009 at 7:25