Example #1
0
Vector *AssemblyMapper_listIdsImpl(AssemblyMapper *am, char *frmSeqRegionName, long frmStart, long frmEnd, CoordSystem *frmCs) {
  IDType seqRegionId = AssemblyMapper_getSeqRegionId(am, frmSeqRegionName, frmCs);
  AssemblyMapperAdaptor *adaptor = AssemblyMapper_getAdaptor(am);

  if ( !CoordSystem_compare(frmCs, AssemblyMapper_getComponentCoordSystem(am) ) ) {

    if ( !AssemblyMapper_haveRegisteredComponent(am, seqRegionId) ) {
      AssemblyMapperAdaptor_registerComponent(adaptor, am, seqRegionId);
    }

    // Pull out the 'from' identifiers of the mapper pairs.  The we
    // loaded the assembled side as the 'from' side in the constructor.

    MapperPairSet *mps = Mapper_listPairs( AssemblyMapper_getMapper(am), seqRegionId, frmStart, frmEnd, "component");

    return MapperPairSet_getFromIds(mps);
  } else if ( !CoordSystem_compare(frmCs, AssemblyMapper_getAssembledCoordSystem(am) ) ) {

    AssemblyMapperAdaptor_registerAssembled(adaptor, am, seqRegionId, frmStart, frmEnd);

    // Pull out the 'to' identifiers of the mapper pairs we loaded the
    // component side as the 'to' coord system in the constructor.

    MapperPairSet *mps = Mapper_listPairs( AssemblyMapper_getMapper(am), seqRegionId, frmStart, frmEnd, "assembled");

    return MapperPairSet_getToIds(mps);
  } else {

    fprintf(stderr, "Coordinate system %s %s is neither the assembled nor the component coordinate system of this AssemblyMapper\n",
                    CoordSystem_getName(frmCs), CoordSystem_getVersion(frmCs) );
    exit(1);

  }
}
Example #2
0
char *CoordSystem_getNameColonVersion(CoordSystem *cs) {
  if (cs && cs->nameColonVersion == NULL) {
    char tmpStr[1024];
    sprintf(tmpStr,"%s:%s",CoordSystem_getName(cs),CoordSystem_getVersion(cs) ? CoordSystem_getVersion(cs):"");
    StrUtil_copyString(&cs->nameColonVersion, tmpStr, 0);
    cs->lenNameColonVersion = strlen(tmpStr);
  }
 
  return cs? cs->nameColonVersion : NULL;
}
Example #3
0
MapperRangeSet *AssemblyMapper_fastMapImpl(AssemblyMapper *am, char *frmSeqRegionName, long frmStart, long frmEnd, int frmStrand, CoordSystem *frmCs, Slice *toSlice) {
  Mapper *mapper  = AssemblyMapper_getMapper(am);
  CoordSystem *asmCs  = AssemblyMapper_getAssembledCoordSystem(am);
  CoordSystem *cmpCs  = AssemblyMapper_getComponentCoordSystem(am);
  AssemblyMapperAdaptor *adaptor = AssemblyMapper_getAdaptor(am);
  char *frm;

  IDType seqRegionId = AssemblyMapper_getSeqRegionId(am, frmSeqRegionName, frmCs);


  // Speed critical section:
  // Try to do simple pointer equality comparisons of the coord system
  // objects first since this is likely to work most of the time and is
  // much faster than a function call.

  if ( frmCs == cmpCs
       || ( frmCs != asmCs && !CoordSystem_compare(frmCs,  cmpCs)) ) {
    if ( !IDHash_contains(AssemblyMapper_getComponentRegister(am), seqRegionId) ) {
      AssemblyMapperAdaptor_registerComponent( adaptor, am, seqRegionId);
    }
    frm = "component";

  } else if ( frmCs == asmCs || !CoordSystem_compare(frmCs, asmCs) ) {
    // This can be probably be sped up some by only calling registered
    // assembled if needed.
    AssemblyMapperAdaptor_registerAssembled( adaptor, am, seqRegionId, frmStart, frmEnd);

    frm = "assembled";
  } else {
    fprintf(stderr,"Coordinate system %s %s is neither the assembled nor the component coordinate system of this AssemblyMapper\n",
            CoordSystem_getName(frmCs), CoordSystem_getVersion(frmCs) );

  }

  return Mapper_fastMap( mapper, seqRegionId, frmStart, frmEnd, frmStrand, frm );
}
Example #4
0
int CoordSystem_compare(CoordSystem *cs1, CoordSystem *cs2) {

/* Dodgy DAS stuff
  if (!$cs2 || !ref($cs2) || !$cs2->isa('Bio::EnsEMBL::CoordSystem')) {
    if ($cs2->isa('Bio::EnsEMBL::ExternalData::DAS::CoordSystem')) {
      return $cs2->equals($self);
    }
    throw('Argument must be a CoordSystem');
  }
*/

  if (!EcoString_strcmp(CoordSystem_getVersion(cs1), CoordSystem_getVersion(cs2)) && !EcoString_strcmp(CoordSystem_getName(cs1), CoordSystem_getName(cs2))) {
    // Equal, so return 0
    return 0;
  }

  return 1;
}