org.intermine.bio.postprocess
Class CalculateLocations

java.lang.Object
  extended by org.intermine.bio.postprocess.CalculateLocations

public class CalculateLocations
extends java.lang.Object

Calculate additional mappings between annotation after loading into genomic ObjectStore. Currently designed to cope with situation after loading ensembl, may need to change as other annotation is loaded. New Locations (and updated BioEntities) are stored back in originating ObjectStore.


Nested Class Summary
protected  class CalculateLocations.SimpleLoc
          Lightweight representation of a Location for easier manipulation and storing in maps.
 
Field Summary
protected  ObjectStore os
           
protected  ObjectStoreWriter osw
           
 
Constructor Summary
CalculateLocations(ObjectStoreWriter osw)
          Create a new CalculateLocations object from an ObjectStoreWriter
 
Method Summary
 void createOverlapRelations(java.util.List<java.lang.String> classNamesToIgnore, boolean ignoreSelfMatches)
          Create OverlapRelation objects for all overlapping SequenceFeatures by querying objects that are located on chromosomes and overlap.
 void createSpanningLocations(java.lang.Class<?> parentClass, java.lang.Class<?> childClass, java.lang.String refField)
          Create a Location that spans the locations of some child objects.
protected static boolean overlap(CalculateLocations.SimpleLoc sl1, CalculateLocations.SimpleLoc sl2)
          Return true if locations of two objects on some parent object have any overlap.
 void setChromosomeLocationsAndLengths()
          For each SequenceFeature, if it has a Location on a Chromosome, set the SequenceFeature.chromosomeLocation reference to be that Location and set the length field of the SequenceFeature to chromosomeLocation.end - chromosomeLocation.start + 1
 void setMissingChromosomeLocations()
          For each SequenceFeature, if it has a Location on a Chromosome, set the SequenceFeature.chromosomeLocation reference *if* the reference is not already set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

osw

protected ObjectStoreWriter osw

os

protected ObjectStore os
Constructor Detail

CalculateLocations

public CalculateLocations(ObjectStoreWriter osw)
Create a new CalculateLocations object from an ObjectStoreWriter

Parameters:
osw - writer on genomic ObjectStore
Method Detail

createOverlapRelations

public void createOverlapRelations(java.util.List<java.lang.String> classNamesToIgnore,
                                   boolean ignoreSelfMatches)
                            throws java.lang.Exception
Create OverlapRelation objects for all overlapping SequenceFeatures by querying objects that are located on chromosomes and overlap.

Parameters:
classNamesToIgnore - a List of the names of those classes that should be ignored when searching for overlaps. Sub classes to these classes are ignored too. In addition, an entry can be of the form class=class, which specifies that the particular combination should be ignored. Hence an entry of the form class is equivalent to class=InterMineObject
ignoreSelfMatches - if true, don't create OverlapRelations between two objects of the same class
Throws:
java.lang.Exception - if anything goes wrong

createSpanningLocations

public void createSpanningLocations(java.lang.Class<?> parentClass,
                                    java.lang.Class<?> childClass,
                                    java.lang.String refField)
                             throws ObjectStoreException
Create a Location that spans the locations of some child objects. eg. create a location for Transcript that is as big as all the exons in it's exons collection. One new location will be created for each possible Location.object - Transcript->Chromosome, Transcript->Contig etc.

Parameters:
parentClass - the parent, eg. Transcript
childClass - the child, eg. Exon
refField - the linking field eg. "exons"
Throws:
ObjectStoreException - if the is a problem with the ObjectStore

setChromosomeLocationsAndLengths

public void setChromosomeLocationsAndLengths()
                                      throws java.lang.Exception
For each SequenceFeature, if it has a Location on a Chromosome, set the SequenceFeature.chromosomeLocation reference to be that Location and set the length field of the SequenceFeature to chromosomeLocation.end - chromosomeLocation.start + 1

Throws:
java.lang.Exception - if anything goes wrong

setMissingChromosomeLocations

public void setMissingChromosomeLocations()
                                   throws java.lang.Exception
For each SequenceFeature, if it has a Location on a Chromosome, set the SequenceFeature.chromosomeLocation reference *if* the reference is not already set.

Throws:
java.lang.Exception - if anything goes wrong

overlap

protected static boolean overlap(CalculateLocations.SimpleLoc sl1,
                                 CalculateLocations.SimpleLoc sl2)
Return true if locations of two objects on some parent object have any overlap.

Parameters:
sl1 - first location
sl2 - second location
Returns:
true if the two locations have any overlap