Пример #1
0
int main(int argc, char *argv[]) {
  DBAdaptor *dba;
  AssemblyMapperAdaptor *asma;
  int testNum = 1;

  initEnsC(argc, argv);

  dba = Test_initROEnsDB();

  //
  // 1 Test AssemblyMapperAdaptor constructor
  //
  asma = DBAdaptor_getAssemblyMapperAdaptor(dba);

  ok(testNum++, asma!=NULL);

  //
  // Test fetch_by_CoordSystems
  //

  CoordSystemAdaptor *csa = DBAdaptor_getCoordSystemAdaptor(dba);

  CoordSystemAdaptor_dumpCachedMappings(csa);

  CoordSystem *toplevelCs  = CoordSystemAdaptor_fetchByName(csa, "toplevel", NULL);
  CoordSystem *clnCs  = CoordSystemAdaptor_fetchByName(csa, "clone", NULL);
  CoordSystem *superctgCs = CoordSystemAdaptor_fetchByName(csa, "supercontig", NULL);

  TopLevelAssemblyMapper *clnToplevelMapper = (TopLevelAssemblyMapper *)AssemblyMapperAdaptor_fetchByCoordSystems(asma, toplevelCs, clnCs);
  TopLevelAssemblyMapper *superctgToplevelMapper = (TopLevelAssemblyMapper *)AssemblyMapperAdaptor_fetchByCoordSystems(asma, toplevelCs, superctgCs);

  ok(testNum++, clnToplevelMapper!=NULL); //  && $cln_toplevel_mapper->isa('Bio::EnsEMBL::TopLevelAssemblyMapper'));
  ok(testNum++, superctgToplevelMapper!=NULL); //  && $cln_toplevel_mapper->isa('Bio::EnsEMBL::TopLevelAssemblyMapper'));


//
// test db has chr 20  (50KB -> 62MB)
//

//
// Test map
//
  MapperRangeSet *coords = NULL;

  if (clnToplevelMapper) {
    fprintf(stderr, "MAP 'AL359765.6'->toplevel\n");
    coords = TopLevelAssemblyMapper_map(clnToplevelMapper,"AL359765.6", 1, 13780, 1, clnCs,  0, NULL);
    printCoords(coords);
    ok(testNum++, coords!=NULL);
  }

  if (superctgToplevelMapper) {
      fprintf(stderr, "MAP NT_028392->toplevel\n");
      coords = TopLevelAssemblyMapper_map(superctgToplevelMapper, "NT_028392", 600000, 1000000, 1, superctgCs, 0, NULL);
      printCoords(coords);
      ok(testNum++, coords!=NULL);
    }


//
// Test list_seq_regions
//
  Vector *seqRegions;
  int i;
    
  if (clnToplevelMapper) {
    seqRegions = TopLevelAssemblyMapper_listSeqRegions(clnToplevelMapper, "AL359765.6", 1, 13780, clnCs);
    ok(testNum++, seqRegions!=NULL && Vector_getNumElement(seqRegions) == 1 && !strcmp("20", Vector_getElementAt(seqRegions,0)));
    for (i=0;i<Vector_getNumElement(seqRegions); i++) {
      char *regionName = Vector_getElementAt(seqRegions, i);
      fprintf(stderr, "%s\n",regionName);
    }
  }

  if (superctgToplevelMapper) {
    seqRegions = TopLevelAssemblyMapper_listSeqRegions(superctgToplevelMapper, "NT_028392", 600000, 1000000, superctgCs);
    ok(testNum++, seqRegions!=NULL && Vector_getNumElement(seqRegions) == 1 && !strcmp("20", Vector_getElementAt(seqRegions,0)));
    for (i=0;i<Vector_getNumElement(seqRegions); i++) {
      char *regionName = Vector_getElementAt(seqRegions, i);
      fprintf(stderr, "%s\n",regionName);
    }
  }

//
// Test list_seq_ids
//
  Vector *ids;

  if (clnToplevelMapper) {
    ids = TopLevelAssemblyMapper_listIds(clnToplevelMapper, "AL359765.6", 1, 13780, clnCs);
    ok(testNum++, ids!=NULL && Vector_getNumElement(ids) == 1 && *((IDType *)Vector_getElementAt(ids,0)) == 469283 );
    for (i=0;i<Vector_getNumElement(ids); i++) {
      IDType id = *((IDType *)Vector_getElementAt(ids, i));
      fprintf(stderr, IDFMTSTR"\n",id);
    }
  }

  if (superctgToplevelMapper) {
    ids = TopLevelAssemblyMapper_listIds(superctgToplevelMapper, "NT_028392", 600000, 1000000, superctgCs);
    ok(testNum++, ids!=NULL && Vector_getNumElement(ids) == 1 && *((IDType *)Vector_getElementAt(ids,0)) == 469283 );
    for (i=0;i<Vector_getNumElement(ids); i++) {
      IDType id = *((IDType *)Vector_getElementAt(ids, i));
      fprintf(stderr, IDFMTSTR"\n",id);
    }
  }

// Test for a not implemented method
//  seqRegions = TopLevelAssemblyMapper_listContigIds(clnToplevelMapper, "AL359765.6", 1, 13780, 1);

  return 0;
}
Пример #2
0
int main(int argc, char *argv[]) {
  DBAdaptor *dba;
  AssemblyMapperAdaptor *asma;
  int testNum = 1;
  
  initEnsC(argc, argv);

  dba = Test_initROEnsDB();

  //
  // 1 Test AssemblyMapperAdaptor constructor
  //
  asma = DBAdaptor_getAssemblyMapperAdaptor(dba);

  ok(testNum++, asma!=NULL);


  //
  // 2 Test fetch_by_CoordSystems
  //

  CoordSystemAdaptor *csa = DBAdaptor_getCoordSystemAdaptor(dba);

  CoordSystemAdaptor_dumpCachedMappings(csa);

  CoordSystem *chrCs  = CoordSystemAdaptor_fetchByName(csa, "chromosome", NULL);
  CoordSystem *clnCs  = CoordSystemAdaptor_fetchByName(csa, "clone", NULL);
  CoordSystem *sCtgCs = CoordSystemAdaptor_fetchByName(csa, "supercontig", NULL);

  ChainedAssemblyMapper *asmMapper =  (ChainedAssemblyMapper *)AssemblyMapperAdaptor_fetchByCoordSystems(asma, clnCs, chrCs);

  ok(testNum++,  asmMapper!=NULL); // Need to make it an object before can do this && asmMapper->objectType == ( "Bio::EnsEMBL::ChainedAssemblyMapper" ));
  
  ChainedAssemblyMapper *chrSCtgMapper = (ChainedAssemblyMapper *)AssemblyMapperAdaptor_fetchByCoordSystems(asma, chrCs, sCtgCs);

  ok(testNum++, chrSCtgMapper!=NULL);// && $chr_sctg_mapper->isa('Bio::EnsEMBL::ChainedAssemblyMapper'));

//
// test db has chr 20  (50KB -> 62MB)
//

  MapperRangeSet *coords;

  if (asmMapper)
    {
      fprintf(stderr,"MAP 20->clone\n");
      coords = ChainedAssemblyMapper_map(asmMapper, "20", 500001, 60000000, 1, chrCs, 0, NULL);
      ok(testNum++, coords!=NULL);
      printCoords(coords);
    }

  if (asmMapper)
    {
      fprintf(stderr,"MAP 'AL359765.6'->chromosome\n");
      coords = ChainedAssemblyMapper_map(asmMapper, "AL359765.6", 1, 13780, 1, clnCs, 0, NULL);
      ok(testNum++, coords!=NULL);
      printCoords(coords);
    }

  if (chrSCtgMapper)
    {
      fprintf(stderr,"MAP 20->supercontig\n");
      coords = ChainedAssemblyMapper_map(chrSCtgMapper, "20", 500001, 60000000, 1, chrCs, 0, NULL);
      ok(testNum++, coords!=NULL);
      printCoords(coords);
    }

  //
  // Test list_seq_regions
  //
  fprintf(stderr,"Starting list tests\n");
  int i;

  if (asmMapper)
    {
      Vector *seqRegions = ChainedAssemblyMapper_listSeqRegions(asmMapper, "20", 500001, 60000000, chrCs);
      ok(testNum++, seqRegions != NULL);
      for (i=0;i<Vector_getNumElement(seqRegions); i++) {
        char *regionName = Vector_getElementAt(seqRegions, i);
        fprintf(stderr, "%s\n",regionName);
      }
    }

  if (asmMapper)
    {
      Vector *seqRegions = ChainedAssemblyMapper_listSeqRegions(asmMapper, "AL359765.6", 1, 13780, clnCs);
      ok(testNum++, seqRegions!=NULL);
      for (i=0;i<Vector_getNumElement(seqRegions); i++) {
        char *regionName = Vector_getElementAt(seqRegions, i);
        fprintf(stderr, "%s\n",regionName);
      }
    }


  if (chrSCtgMapper)
    {
      Vector *seqRegions = ChainedAssemblyMapper_listSeqRegions(chrSCtgMapper, "NT_028392", 600000, 1000000, sCtgCs);
      ok(testNum++, seqRegions!=NULL);
      for (i=0;i<Vector_getNumElement(seqRegions); i++) {
        char *regionName = Vector_getElementAt(seqRegions, i);
        fprintf(stderr, "%s\n",regionName);
      }
    }

  if (chrSCtgMapper)
    {
      Vector *seqRegions = ChainedAssemblyMapper_listSeqRegions(chrSCtgMapper, "20", 3000000, 31000000, chrCs);
      ok(testNum++, seqRegions!=NULL);
      for (i=0;i<Vector_getNumElement(seqRegions); i++) {
        char *regionName = Vector_getElementAt(seqRegions, i);
        fprintf(stderr, "%s\n",regionName);
      }
    }



  //
  // Test list_seq_ids
  //

  if (asmMapper)
    {
      Vector *seqIds = ChainedAssemblyMapper_listIds(asmMapper, "20", 500001, 60000000, chrCs);

      ok(testNum++, seqIds!=NULL);
      for (i=0;i<Vector_getNumElement(seqIds); i++) {
        IDType regionId = *((IDType *)Vector_getElementAt(seqIds, i));
        fprintf(stderr, IDFMTSTR"\n",regionId);
      }
    }

  if (asmMapper)
    {
      Vector *seqIds = ChainedAssemblyMapper_listIds(asmMapper, "AL359765.6", 1, 13780, clnCs);
      ok(testNum++, seqIds!=NULL);
      for (i=0;i<Vector_getNumElement(seqIds); i++) {
        IDType regionId = *((IDType *)Vector_getElementAt(seqIds, i));
        fprintf(stderr, IDFMTSTR"\n",regionId);
      }
    }

  if (chrSCtgMapper)
    {
      Vector *seqIds = ChainedAssemblyMapper_listIds(chrSCtgMapper, "NT_028392", 600000, 1000000, sCtgCs);
      ok(testNum++, seqIds!=NULL);
      for (i=0;i<Vector_getNumElement(seqIds); i++) {
        IDType regionId = *((IDType *)Vector_getElementAt(seqIds, i));
        fprintf(stderr, IDFMTSTR"\n",regionId);
      }
    }

  if (chrSCtgMapper)
    {
      Vector *seqIds = ChainedAssemblyMapper_listIds(chrSCtgMapper, "20", 3000000, 31000000, chrCs);
      ok(testNum++, seqIds!=NULL);
      for (i=0;i<Vector_getNumElement(seqIds); i++) {
        IDType regionId = *((IDType *)Vector_getElementAt(seqIds, i));
        fprintf(stderr, IDFMTSTR"\n",regionId);
      }
    }

  return 0;
  
}