Пример #1
0
int main(int argc, char *argv[]) {
  DBAdaptor *dba;
  Slice *slice;
  SliceAdaptor *sliceA;
  SequenceAdaptor *seqA;

  initEnsC(argc, argv);

  dba = DBAdaptor_new("ensembldb.ensembl.org","anonymous",NULL,"homo_sapiens_core_70_37",5306,NULL);
  //dba = DBAdaptor_new("ens-livemirror.internal.sanger.ac.uk","ensro",NULL,"homo_sapiens_core_70_37",3306,NULL);
  //dba = DBAdaptor_new("genebuild2.internal.sanger.ac.uk","ensadmin","ensembl","steve_hs_testdb",3306,NULL);

  sliceA = DBAdaptor_getSliceAdaptor(dba);
  seqA = DBAdaptor_getSequenceAdaptor(dba);

//
// Test fetch_by_Slice_start_end_strand
//
  slice = SliceAdaptor_fetchByRegion(sliceA,"chromosome",CHR,START,END,STRAND,NULL,0);
  compareComplements(slice, seqA);

  slice = SliceAdaptor_fetchByRegion(sliceA, "clone","AL031658.11", POS_UNDEF, POS_UNDEF, STRAND_UNDEF, NULL, 0);
  compareComplements(slice, seqA);

  slice = SliceAdaptor_fetchByRegion(sliceA, "supercontig","NT_028392", POS_UNDEF, POS_UNDEF, STRAND_UNDEF, NULL, 0);
  compareComplements(slice, seqA);

  slice = SliceAdaptor_fetchByRegion(sliceA, "contig", "AL031658.11.1.162976", POS_UNDEF, POS_UNDEF, STRAND_UNDEF, NULL, 0);
  compareComplements(slice, seqA);

  return 0;
}
Пример #2
0
int main(int argc, char *argv[]) {
  Vector *pieces;
  char *str;
  char *reverse;
  int testResult = 0;

  initEnsC(argc, argv);

  pieces = CigarStrUtil_getPieces(cigar1);

  testResult += ok(1, Vector_getNumElement(pieces) == 6);
  
  str = Vector_getElementAt(pieces,0);

  testResult += ok(2, !strcmp(str,"6M"));

  Vector_free(pieces);

  StrUtil_copyString(&str,cigar1,0);
  
  testResult += ok(3, !strcmp(str,cigar1));
  
  reverse = CigarStrUtil_reverse(str,strlen(str));
  free(str);

  pieces = CigarStrUtil_getPieces(reverse);

  testResult += ok(4, Vector_getNumElement(pieces) == 6);

  str = Vector_getElementAt(pieces,0);

  testResult += ok(5, !strcmp(str,"M"));

  return testResult;
}
Пример #3
0
int main(int argc, char *argv[]) {
  ComparaDBAdaptor *cdba;

  initEnsC(argc, argv);

  cdba = ComparaDBAdaptor_new("kaka.sanger.ac.uk","anonymous",NULL,"ensembl_compara_14_1",3306,"Tests/Compara.conf");


  return 0;
}
Пример #4
0
int main(int argc, char *argv[]) {
  DBAdaptor *dba;
  RepeatFeatureAdaptor *rfa;
  Slice *slice;
  Vector *features;
  int i;
  int failed;
  
  initEnsC(argc, argv);

  dba = Test_initROEnsDB();

  slice = Test_getStandardSlice(dba);

  ok(1, slice!=NULL);

  rfa = DBAdaptor_getRepeatFeatureAdaptor(dba);

  ok(2, rfa!=NULL);

  features =  Slice_getAllRepeatFeatures(slice,NULL,NULL, NULL);

  ok(3, features!=NULL);
  ok(4, Vector_getNumElement(features)!=0);

  failed = 0;
  for (i=0;i<Vector_getNumElement(features) && !failed;i++) {
    RepeatFeature *rf = Vector_getElementAt(features,i);
    int start = RepeatFeature_getStart(rf);
    int end   = RepeatFeature_getEnd(rf);
    Vector *rrfVector;
    RepeatFeature *rrf;

    printf("slice start = %d end = %d\n",start,end);
/*
    rrfVector = RepeatFeature_transformToRawContig(rf);
    if (Vector_getNumElement(rrfVector) > 1) {
      printf("Feature mapped to more than one rawcontig\n");
      failed=1;
    }
    rrf = Vector_getElementAt(rrfVector,0);

    //printf("rc start = %d end = %d\n",RepeatFeature_getStart(rrf),RepeatFeature_getEnd(rrf));
    rf = RepeatFeature_transformToSlice(rrf, slice);
    if (RepeatFeature_getStart(rf) != start ||
        RepeatFeature_getEnd(rf) != end) {
      printf("Remapping to slice produced different coords\n");
      failed =1;
    }
*/
  }
  ok(5, !failed);
  return 0;
}
Пример #5
0
int main(int argc, char *argv[]) {
  DBAdaptor *dba;
  DBAdaptor *writeDba;
  ProteinAlignFeatureAdaptor *pafa;
  Slice *slice;
  Vector *features;
  int i;
  int failed;
  
  initEnsC(argc, argv);

  dba = Test_initROEnsDB();

  writeDba = Test_initRWEnsDB();

  slice = Test_getStandardSlice(dba);

  ok(1, slice!=NULL);

  pafa = DBAdaptor_getProteinAlignFeatureAdaptor(writeDba);
  SliceAdaptor *sa = DBAdaptor_getSliceAdaptor(dba);

  ok(2, pafa!=NULL);

  //features =  Slice_getAllDNAPepAlignFeatures(slice,NULL,NULL, NULL,NULL);

  //Slice *slice3 = SliceAdaptor_fetchByRegion(sa,"chromosome","1",2,260000000,1,NULL,0);
  Slice *slice2 = SliceAdaptor_fetchByRegion(sa,"chromosome","1",1000000,4000000,1,NULL,0);
  features =  Slice_getAllProteinAlignFeatures(slice2,NULL,NULL, NULL,NULL);

  ok(3, features!=NULL);
  ok(4, Vector_getNumElement(features)!=0);

  ProteinAlignFeatureAdaptor_store((BaseFeatureAdaptor*)pafa, features);

  return 0;
}
Пример #6
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;
}
Пример #7
0
int main(int argc, char *argv[]) {

  initEnsC(argc, argv);

  Mapper *mapper = Mapper_new( "rawcontig", "virtualcontig", NULL, NULL );
  int nToLoad = loadSGPDump(mapper, 0 );

  // loading done successfully
  ok(1,  nToLoad == 100);


  {
    // transform a segment entirely within the first rawcontig
    int testOutput[][4] = {1, 2, 5, -1};
    testTransform (mapper, 627012, 2, 5, -1, "rawcontig", testOutput, NumOutput(testOutput));
  }
  
  {
    // now a split coord
    int testOutput[][4] = {
                          {314696, 31917, 31937, -1},
                          {341, 126, 59773, -1},
                          {315843, 5332, 5963, +1}
                         };
    testTransform (mapper, 1, 383700, 444000, +1, "virtualcontig",testOutput, NumOutput(testOutput));
  }
  
  {
    // now a simple gap
    int testOutput[][4] = {
                          { 627011, 7447, 7507, +1 },
                          { 1, 273762, 273781, 0 }
                          };
    testTransform (mapper, 1, 273701, 273781, +1, "virtualcontig", testOutput, NumOutput(testOutput));
  }
  
  //
  // check if the mapper can do merging
  // 
  
  mapper = Mapper_new( "asm1", "asm2", NULL, NULL );
  
  Mapper_addMapCoordinates(mapper, 1, 1, 10, 1, 1, 101, 110 );
  Mapper_addMapCoordinates(mapper, 1, 21, 30, 1, 1, 121, 130 );
  Mapper_addMapCoordinates(mapper, 1, 11, 20, 1, 1, 111, 120 );
  
  
  {
    int testOutput[][4] = {{ 1, 105, 125, 1 }};
    testTransform(mapper, 1, 5, 25, 1, "asm1", testOutput, NumOutput(testOutput));
  }
  
  
  
  //
  // Slightly differnt merge case
  //
  mapper = Mapper_new( "asm1", "asm2", NULL, NULL );
  
  Mapper_addMapCoordinates(mapper, 1, 1, 10, 1, 1, 101, 110 );
  Mapper_addMapCoordinates(mapper, 1, 21, 30, 1, 1, 121, 130 );
  Mapper_addMapCoordinates(mapper, 1, 12, 20, 1, 1, 112, 120 );
  
  {
    int testOutput[][4] = {
                           { 1, 105, 110, 1 },
                           { 1, 11, 11, 0 },
                           { 1, 112, 125, 1 }
                          };
    testTransform( mapper, 1, 5, 25, 1, "asm1" , testOutput, NumOutput(testOutput));
  }
  
  
  
  //
  // dont merge on wrong orientation
  //
  
  mapper = Mapper_new( "asm1", "asm2", NULL, NULL );
  
  Mapper_addMapCoordinates(mapper, 1, 1, 10, 1, 1, 101, 110 );
  Mapper_addMapCoordinates(mapper, 1, 21, 30, 1, 1, 121, 130 );
  Mapper_addMapCoordinates(mapper, 1, 11, 20, -1, 1, 111, 120 );
  
  {
    int testOutput[][4] = {
                           { 1, 105, 110, 1 },
                           { 1, 111, 120, -1 },
                           { 1, 121, 125, 1 }
                          };
    testTransform( mapper,  1, 5, 25, 1, "asm1" , testOutput, NumOutput(testOutput));
  }
  
  //
  // can reverse strands merge?
  //
  
  mapper = Mapper_new( "asm1", "asm2", NULL, NULL );
  
  Mapper_addMapCoordinates(mapper, 1, 1, 10, -1, 1, 121, 130 );
  Mapper_addMapCoordinates(mapper, 1, 21, 30, -1, 1, 101, 110 );
  Mapper_addMapCoordinates(mapper, 1, 11, 20, -1, 1, 111, 120 );
  
  {
    int testOutput[][4] = {{ 1, 106, 126, -1 } };
    testTransform( mapper, 1, 5, 25, 1, "asm1", testOutput, NumOutput(testOutput));
  }
  
  
  //
  // normal merge, not three
  //
  
  mapper = Mapper_new( "asm1", "asm2", NULL, NULL );
  
  Mapper_addMapCoordinates(mapper, 1, 1, 10, 1, 1, 101, 110 );
  Mapper_addMapCoordinates(mapper, 1, 11, 20, 1, 1, 111, 120 );
  Mapper_addMapCoordinates(mapper, 1, 22, 30, 1, 1, 132, 140 );
  Mapper_addMapCoordinates(mapper, 1, 51, 70, 1, 1, 161, 180 );
  Mapper_addMapCoordinates(mapper, 1, 31, 35, 1, 1, 141, 145 );
  
  {
    int testOutput[][4] = {
                           { 1, 105, 120, 1 },
                           { 1, 21, 21, 0 },
                           { 1, 132, 145, 1 },
                           { 1, 36, 45, 0 }
                          };
    testTransform( mapper, 1, 5, 45, 1, "asm1" , testOutput, NumOutput(testOutput));
  }
  
  
  //
  // test tranformation of 'insertion' coordinates where end = start -1
  //
  
  mapper = Mapper_new("asm1", "asm2", NULL, NULL);
  
  Mapper_addMapCoordinates(mapper,1, 1, 10, 1, 2, 101, 110);
  Mapper_addMapCoordinates(mapper,1, 11, 20, -1, 3, 1, 10);
  
  {
    // boundary insert, expect 2 edge inserts back
    int testOutput[][4] = {
                           {2, 111, 110, 1},
                           {3, 11,  10, -1}
                          };
    testTransform(mapper, 1, 11, 10, 1, "asm1", testOutput, NumOutput(testOutput));
  }
  
  {
    // edge insert, negative strand, expect edge insert negative strand
    int testOutput[][4] = {{2, 101, 100, -1}};
    testTransform(mapper, 1, 1, 0, -1, "asm1", testOutput, NumOutput(testOutput));
  }
  
  {
    // normal case, expect single insert in middle
    int testOutput[][4] = {{2, 102, 101, 1}};
    testTransform(mapper, 1, 2, 1, 1, "asm1", testOutput, NumOutput(testOutput));
  }
  
  {
    // expect a gap
    int testOutput[][4] = {{1, 100, 200, 0}};
    testTransform(mapper, 1, 100, 200, 1, "asm1", testOutput, NumOutput(testOutput));
  }
  
  return 0;
}
Пример #8
0
int main(int argc, char *argv[]) {
  DBAdaptor *      dba;
  StatementHandle *sth;
  ResultRow *      row;
  Vector *         slices;
  int              nSlices;
  htsFile *      out;

  int   argNum = 1;

  char *inFName  = NULL;
  char *outFName = NULL;

  char *dbUser = "******";
  char *dbPass = NULL;
  int   dbPort = 3306;

  char *dbHost = "ens-staging.internal.sanger.ac.uk";
  char *dbName = "homo_sapiens_core_71_37";

  char *assName = "GRCh37";

  char *chrName = "1";


  int flags = 0;
  int   threads  = 1;

  initEnsC(argc, argv);

  while (argNum < argc) {
    char *arg = argv[argNum];
    char *val;

// Ones without a val go here
    if (!strcmp(arg, "-U") || !strcmp(arg,"--ucsc_naming")) {
      flags |= M_UCSC_NAMING;
    } else {
// Ones with a val go in this block
      if (argNum == argc-1) {
        Bamcov_usage();
      }

      val = argv[++argNum];
  
      if (!strcmp(arg, "-i") || !strcmp(arg,"--in_file")) {
        StrUtil_copyString(&inFName,val,0);
      } else if (!strcmp(arg, "-o") || !strcmp(arg,"--out_file")) {
        StrUtil_copyString(&outFName,val,0);
      } else if (!strcmp(arg, "-h") || !strcmp(arg,"--host")) {
        StrUtil_copyString(&dbHost,val,0);
      } else if (!strcmp(arg, "-p") || !strcmp(arg,"--password")) {
        StrUtil_copyString(&dbPass,val,0);
      } else if (!strcmp(arg, "-P") || !strcmp(arg,"--port")) {
        dbPort = atoi(val);
      } else if (!strcmp(arg, "-n") || !strcmp(arg,"--name")) {
        StrUtil_copyString(&dbName,val,0);
      } else if (!strcmp(arg, "-u") || !strcmp(arg,"--user")) {
        StrUtil_copyString(&dbUser,val,0);
      } else if (!strcmp(arg, "-t") || !strcmp(arg,"--threads")) {
        threads = atoi(val);
      } else if (!strcmp(arg, "-a") || !strcmp(arg,"--assembly")) {
        StrUtil_copyString(&assName,val,0);
      } else if (!strcmp(arg, "-v") || !strcmp(arg,"--verbosity")) {
        verbosity = atoi(val);
// Temporary
      } else if (!strcmp(arg, "-c") || !strcmp(arg,"--chromosome")) {
        StrUtil_copyString(&chrName,val,0);
      } else {
        fprintf(stderr,"Error in command line at %s\n\n",arg);
        Bamcov_usage();
      }
    }
    argNum++;
  }

  if (verbosity > 0) {
    printf("Program for calculating read coverage in a BAM file \n"
           "Steve M.J. Searle.  [email protected]  Last update April 2013.\n");
  }

  if (!inFName || !outFName) {
    Bamcov_usage();
  }

  dba = DBAdaptor_new(dbHost,dbUser,dbPass,dbName,dbPort,NULL);

  //nSlices = getSlices(dba, destName);
  nSlices = 1;

  slices = Vector_new();

  SliceAdaptor *sa = DBAdaptor_getSliceAdaptor(dba);

  Slice *slice = SliceAdaptor_fetchByRegion(sa,NULL,chrName,POS_UNDEF,POS_UNDEF,1,NULL, 0);

  Vector_addElement(slices,slice);

  if (Vector_getNumElement(slices) == 0) {
    fprintf(stderr, "Error: No slices.\n");
    exit(1);
  }

  htsFile *in = hts_open(inFName, "rb");
  if (in == 0) {
    fprintf(stderr, "Fail to open BAM file %s\n", inFName);
    return 1;
  }

  hts_set_threads(in, threads);
  hts_idx_t *idx;
  idx = bam_index_load(inFName); // load BAM index
  if (idx == 0) {
    fprintf(stderr, "BAM index file is not available.\n");
    return 1;
  }

  int i;
  for (i=0; i<Vector_getNumElement(slices); i++) {
    Slice *slice = Vector_getElementAt(slices,i);

    if (verbosity > 0) printf("Working on '%s'\n",Slice_getName(slice));

//    if (verbosity > 0) printf("Stage 1 - retrieving annotation from database\n");
//    Vector *genes = getGenes(slice, flags);

    if (verbosity > 0) printf("Stage 1 - calculating coverage\n");
    calcCoverage(inFName, slice, in, idx, flags);
  }


  hts_idx_destroy(idx);
  hts_close(in);

  if (verbosity > 0) printf("Done\n");
  return 0;
}
Пример #9
0
int main(int argc, char *argv[]) {
  DBAdaptor *dba;
  GeneAdaptor *ga;
  Slice *slice = NULL;
  Vector *genes = NULL;
  int i = 0;
  int failed = 0;
  
  initEnsC(argc, argv);

//  ProcUtil_showBacktrace(EnsC_progName);

  dba = Test_initROEnsDB();
  slice = Test_getStandardSlice(dba);

//  DBAdaptor *seqdba = DBAdaptor_new("genebuild6.internal.sanger.ac.uk","ensadmin","ensembl","steve_chicken_rnaseq_missing_reference",3306,NULL);
//  dba = DBAdaptor_new("genebuild1.internal.sanger.ac.uk","ensadmin","ensembl","steve_chicken_rnaseq_missing_refined",3306,seqdba);

  ok(1, slice!=NULL);

  ga = DBAdaptor_getGeneAdaptor(dba);
  SliceAdaptor *sa = DBAdaptor_getSliceAdaptor(dba);

  ok(2, ga!=NULL);

  slice = SliceAdaptor_fetchByRegion(sa,"chromosome","20",10000000,50000000,1,NULL,0);
//  slice = SliceAdaptor_fetchByRegion(sa,"chromosome","17",1000000,5000000,1,NULL,0);
//  slice = SliceAdaptor_fetchByRegion(sa,"chromosome","17",1,5000000,1,NULL,0);
// Has a seleno
//  slice = SliceAdaptor_fetchByRegion(sa,"chromosome","1",1000000,27000000,1,NULL,0);
//  slice = SliceAdaptor_fetchByRegion(sa,"chromosome","MT",1,17000,1,NULL,0);
  genes =  Slice_getAllGenes(slice, NULL, NULL, 1, NULL, NULL);

  fprintf(stdout, "Have %d genes\n", Vector_getNumElement(genes));
  ok(3, genes!=NULL);
  ok(4, Vector_getNumElement(genes)!=0);

  failed = dumpGenes(genes, 1);
  ok(5, !failed);

  //Vector *toplevelSlices = SliceAdaptor_fetchAll(sa, "toplevel", NULL, 0);
  Vector *toplevelSlices = SliceAdaptor_fetchAll(sa, "chromosome", NULL, 0);

  for (i=0;i<Vector_getNumElement(toplevelSlices) && !failed;i++) {
    Slice *tlSlice = Vector_getElementAt(toplevelSlices, i);
    fprintf(stderr, "Slice %s\n", Slice_getName(tlSlice));
    genes =  Slice_getAllGenes(tlSlice, NULL, NULL, 1, NULL, NULL);
    fprintf(stderr, "Got %d genes on %s\n", Vector_getNumElement(genes), Slice_getName(tlSlice));
    failed = dumpGenes(genes, 0);
  }

  //tc_malloc_stats();

  fprintf(stderr,"\nEcostring table stats:\n");
  EcoString_getInfo(ecoSTable);

  fprintf(stderr,"\n");
  ProcUtil_timeInfo("at end of GeneTest");

  return 0;
}
Пример #10
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;
  
}