Package Bio :: Package GFF :: Module easy :: Class Location
[hide private]
[frames] | no frames]

Class Location

source code

          object --+        
                   |        
                list --+    
                       |    
GenericTools.VerboseList --+
                           |
                          Location
Known Subclasses:


this is really best interfaced through LocationFromString
fuzzy: < or >
join: {0 = no join, 1 = join, 2 = order}

>>> location = Location([Location([339]), Location([564])]) # zero-based
>>> location
Location(Location(339), Location(564))
>>> print location # one-based
340..565
>>> print location.five_prime()
340
>>> location_rev = Location([Location([339]), Location([564])], 1)
>>> print location_rev
complement(340..565)
>>> print location_rev.five_prime()
565

Instance Methods [hide private]
new list

__init__(self, the_list, complement=0, seqname=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_joinstr(self) source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
direction_and_index(self, direction)
1: 5' -1: 3'
source code
 
findside(self, direction)
>>> loc = LocationFromString("complement(join(1..5,complement(6..10)))")...
source code
 
findseqname_3prime(self)
>>> loc = LocationFromString("complement(join(MOOCOW:1..5,SEQ:complement(6..10)))")...
source code
 
findseqname(self, direction=1)
>>> loc = LocationFromString("complement(join(MOOCOW:1..5,SEQ:complement(6..10)))")...
source code
 
five_prime(self) source code
 
three_prime(self) source code
 
length(self)
WARNING: doesn't deal with joins!!!!
source code
 
intersection(self, other)
WARNING: doesn't deal with joins!!!!
source code
 
start(self) source code
 
end(self) source code
 
three_prime_range(self, window) source code
 
sublocation(self, sub_location)
>>> fwd_location = LocationFromString('X:5830132..5831528')...
source code
 
__add__(self, addend)
x+y
source code
 
add(self, addend, complement=0) source code
 
__sub__(self, subtrahend) source code
 
reverse(self)
reverse *IN PLACE*
source code
 
reorient(self)
>>> loc1 = LocationFromString("join(I:complement(1..9000),I:complement(9001..10000))")...
source code
 
bounding(self)
works for single level non-complex joins
source code

Inherited from list: __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __hash__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __reversed__, __rmul__, __setitem__, __setslice__, append, count, extend, index, insert, pop, remove, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Class Variables [hide private]
  direction2index = {-1: -1, 1: 0}
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, the_list, complement=0, seqname=None)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Returns:
new list

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)

Overrides: object.__repr__
(inherited documentation)

direction_and_index(self, direction)

source code 

1: 5'
-1: 3'

>>> loc1 = LocationFromString("join(1..3,complement(5..6))")
>>> loc1.direction_and_index(1)
(1, 0)
>>> loc1.direction_and_index(-1)
(-1, -1)
>>> loc1.reverse()
>>> print loc1
complement(join(1..3,complement(5..6)))
>>> loc1.direction_and_index(1)
(-1, -1)

findside(self, direction)

source code 

>>> loc = LocationFromString("complement(join(1..5,complement(6..10)))")
>>> loc.findside(1)
Location(5)
>>> loc.findside(-1)
Location(0)

findseqname_3prime(self)

source code 

>>> loc = LocationFromString("complement(join(MOOCOW:1..5,SEQ:complement(6..10)))")
>>> loc.findseqname_3prime()
'MOOCOW'

findseqname(self, direction=1)

source code 

>>> loc = LocationFromString("complement(join(MOOCOW:1..5,SEQ:complement(6..10)))")
>>> loc.findseqname()
'SEQ'
>>> loc.findseqname(-1)
'MOOCOW'

intersection(self, other)

source code 

WARNING: doesn't deal with joins!!!!

>>> location1 = LocationFromString("1..50")
>>> location2 = LocationFromString("25..200")
>>> print location1.intersection(location2)
25..50
>>> print location1.intersection(location2)
25..50

sublocation(self, sub_location)

source code 

>>> fwd_location = LocationFromString('X:5830132..5831528')
>>> print fwd_location.sublocation(LocationFromString('1..101'))
X:5830132..5830232
>>> print fwd_location.sublocation(LocationFromString('1267..1286'))
X:5831398..5831417
>>> rev_location = LocationFromString('I:complement(8415686..8416216)')
>>> print rev_location.sublocation(LocationFromString('1..101'))
I:complement(8416116..8416216)
>>> print rev_location.sublocation(LocationFromString('100..200'))
I:complement(8416017..8416117)

__add__(self, addend)
(Addition operator)

source code 
x+y

Overrides: list.__add__
(inherited documentation)

reverse(self)

source code 
reverse *IN PLACE*

Overrides: list.reverse
(inherited documentation)

reorient(self)

source code 

>>> loc1 = LocationFromString("join(I:complement(1..9000),I:complement(9001..10000))")
>>> loc1.reorient()
>>> print loc1
complement(join(I:1..9000,I:9001..10000))
>>> loc2 = LocationFromString("join(I:complement(1..9000),I:9001..10000)")
>>> loc2.reorient()
>>> print loc2
join(I:complement(1..9000),I:9001..10000)

bounding(self)

source code 

works for single level non-complex joins

>>> LOC = LocationFromString
>>> l1 = LOC("join(alpha:1..30,alpha:50..70)")
>>> print l1.bounding()
join(alpha:1..70)
>>> l2 = LOC("join(alpha:1..30,alpha:complement(50..70))")
>>> print l2.bounding()
join(alpha:1..30,alpha:complement(50..70))
>>> l3 = LOC("join(alpha:1..30,alpha:complement(50..70),beta:6..20,alpha:25..45)")
>>> print l3.bounding()
join(alpha:1..45,alpha:complement(50..70),beta:6..20)