コード例 #1
0
ファイル: cov_der.cpp プロジェクト: sunpho84/sunpho
int main(int narg,char **arg)
{
  if(narg<2) crash("Use %s path",arg[0]);
  base_path=arg[1];

  //define indices mapping
  indices_t PLAIN,GI_DI,GI,EPSIJK_GJ_DK;
  PLAIN.add(0,0,0,+1);

  for(int i=0;i<3;i++)
    {
      GI.add(i+1,i+1,0,+1);
      GI_DI.add(i+1,i+1,i+1,+1);

      EPSIJK_GJ_DK.add(i+1,1+(i+1)%3,1+(i+2)%3,+1);
      EPSIJK_GJ_DK.add(i+1,1+(i+2)%3,1+(i+1)%3,-1);
    }

  ///////////////////////////////// 0-+ (pseudoscalar) //////////////////////////

  oper_t P5_LOC(SPIN0,PLAIN,"P5",0 ,0);
  oper_t P5_SME(SPIN0,PLAIN,"P5",NSME,0);
  oper_t A0_LOC(SPIN0,PLAIN,"A0",0 ,0);
  oper_t A0_SME(SPIN0,PLAIN,"A0",NSME,0);
  oper_t B1XD_A1_LOC(SPIN0,GI_DI,"C%d",0 ,0);
  oper_t B1XD_A1_SME(SPIN0,GI_DI,"C%d",NSME,0);
  
  const int nop_pseudoscalar=6;
  oper_t ops_pseudoscalar[nop_pseudoscalar]={P5_LOC,A0_LOC,B1XD_A1_LOC,P5_SME,A0_SME,B1XD_A1_SME};
  
  prepare_table("ops_pseudoscalar",nop_pseudoscalar,ops_pseudoscalar,combine("%s/out_pseudoscalar.xmg",base_path).c_str());
  
  return 0;
  
  /////////////////////////////////// 1-- (vector) ///////////////////////////////
  
  cout<<"prepare vector"<<endl;
  oper_t VK_LOC(SPIN1,GI,"V%d",0,0);
  oper_t VK_SME(SPIN1,GI,"V%d",NSME,0);
  oper_t TK_LOC(SPIN1,GI,"T%d",0,0);
  oper_t TK_SME(SPIN1,GI,"T%d",NSME,0);
  oper_t A0XD_T1_LOC(SPIN1,GI_DI,"S0",0,0);
  oper_t A0XD_T1_SME(SPIN1,GI_DI,"S0",NSME,0);
  oper_t A1XD_T1_LOC(SPIN1,EPSIJK_GJ_DK,"A%d",0 ,0);
  oper_t A1XD_T1_SME(SPIN1,EPSIJK_GJ_DK,"A%d",NSME,0);
  const int nop_vectorial=8;
  //oper_t ops_vectorial[nop_vectorial]={A1XD_T1_LOC,A1XD_T1_SME};
  oper_t ops_vectorial[nop_vectorial]={VK_LOC,TK_LOC,A0XD_T1_LOC,A1XD_T1_LOC,VK_SME,TK_SME,A0XD_T1_SME,A1XD_T1_SME};
  prepare_table("ops_vectorial",nop_vectorial,ops_vectorial,combine("%s/out_vectorial.xmg",base_path).c_str());
  
  return 0;
}
コード例 #2
0
ファイル: pl-sequence.c プロジェクト: Bhumi28/sra-tools
/* special case for SEQUENCE: in order to prepare the cursor correctly, we have to know the first HDF5-source-obj !*/
rc_t prepare_seq( VDatabase * database, seq_ctx * sctx, KDirectory * hdf5_src, ld_context *lctx )
{
    rc_t rc = prepare_table( database, &sctx->cursor, seq_schema_template, seq_table_to_create ); /* pl-tools.c ... this creates the cursor */
    sctx->src_open = false;
    if ( rc == 0 )
    {
        rc = open_BaseCalls( hdf5_src, &sctx->BaseCallsTab, "PulseData/BaseCalls", lctx->cache_content, &sctx->rgn_present );
        if ( rc == 0 )
        {
            int32_t to_exclude;

            /* depending on the bit-size of the PulseIndex-table in HDF5
               exclude the opposite column from VDB */
            if ( sctx->BaseCallsTab.PulseIndex.element_bits == PULSE_INDEX_BITSIZE_16 )
                to_exclude = seq_tab_PULSE_INDEX_32;
            else
                to_exclude = seq_tab_PULSE_INDEX_16;

            /* add all columns to the vdb-cursor */
            rc = add_columns( sctx->cursor, seq_tab_count, to_exclude, sctx->col_idx, seq_tab_names );
            if ( rc == 0 )
            {
                rc = VCursorOpen( sctx->cursor );
                if ( rc != 0 )
                {
                    LOGERR( klogErr, rc, "cannot open cursor on seq-table" );
                }
                else
                {
                    const uint8_t platform = SRA_PLATFORM_PACBIO_SMRT;

                    rc = VCursorDefault ( sctx->cursor, sctx->col_idx[ seq_tab_PLATFORM ], 8, &platform, 0, 1 );
                    if ( rc != 0 )
                    {
                        LOGERR( klogErr, rc, "cannot set cursor-default on seq-table for platform-column" );
                    }
                    else
                    {
                        sctx->src_open = true;
                        sctx->lctx = lctx;
                    }
                }
            }
        }
    }
    return rc;
}
コード例 #3
0
ファイル: pl-consensus.c プロジェクト: DCGenomics/sra-tools
rc_t prepare_consensus( VDatabase * database, con_ctx * sctx, ld_context *lctx )
{
    rc_t rc = prepare_table( database, &sctx->cursor,
            consensus_schema_template, consensus_table_to_create ); /* pl-tools.c ... this creates the cursor */
    if ( rc == 0 )
    {
        rc = add_columns( sctx->cursor, consensus_tab_count, -1, sctx->col_idx, consensus_tab_names );
        if ( rc == 0 )
        {
            rc = VCursorOpen( sctx->cursor );
            if ( rc != 0 )
            {
                LOGERR( klogErr, rc, "cannot open cursor on consensus-table" );
            }
            else
            {
                const INSDC_SRA_platform_id platform = SRA_PLATFORM_PACBIO_SMRT;

                rc = VCursorDefault ( sctx->cursor, sctx->col_idx[ consensus_tab_PLATFORM ],
                                      sizeof platform * 8, &platform, 0, 1 );
                if ( rc != 0 )
                {
                    LOGERR( klogErr, rc, "cannot set cursor-default on consensus-table for platform-column" );
                }
                else
                {
                    const INSDC_SRA_read_filter filter = SRA_READ_FILTER_PASS;
                    rc = VCursorDefault ( sctx->cursor, sctx->col_idx[ consensus_tab_READ_FILTER ],
                                      sizeof filter * 8, &filter, 0, 1 );
                    if ( rc != 0 )
                    {
                        LOGERR( klogErr, rc, "cannot set cursor-default on consensus-table for read-filter-column" );
                    }
                    else
                    {
                        sctx->lctx = lctx;
                    }
                }
            }
        }
    }
    return rc;
}
コード例 #4
0
ファイル: pl-passes.c プロジェクト: Bhumi28/sra-tools
rc_t prepare_passes( VDatabase * database, pas_ctx * sctx, ld_context *lctx )
{
    rc_t rc = prepare_table( database, &sctx->cursor,
            passes_schema_template, passes_table_to_create ); /* pl-tools.c ... this creates the cursor */
    if ( rc == 0 )
    {
        rc = add_columns( sctx->cursor, passes_tab_count, -1, sctx->col_idx, passes_tab_names );
        if ( rc == 0 )
        {
            rc = VCursorOpen( sctx->cursor );
            if ( rc != 0 )
            {
                LOGERR( klogErr, rc, "cannot open cursor on PASSES-tab" );
            }
            else
            {
                sctx->lctx = lctx;
            }
        }
    }
    return rc;
}
コード例 #5
0
ファイル: Printer.c プロジェクト: tathougies/hos-old
extern void DEBUG_LoadSymbols( char *name )
{
    bfd* abfd;
    char **matching;

    bfd_init();
    abfd = bfd_openr(name, "default");
    if (abfd == NULL) {
	barf("can't open executable %s to get symbol table", name);
    }
    if (!bfd_check_format_matches (abfd, bfd_object, &matching)) {
	barf("mismatch");
    }

    {
	long storage_needed;
	asymbol **symbol_table;
	long number_of_symbols;
        long num_real_syms = 0;
	long i;
     
	storage_needed = bfd_get_symtab_upper_bound (abfd);
     
	if (storage_needed < 0) {
	    barf("can't read symbol table");
	}     
#if 0
	if (storage_needed == 0) {
	    debugBelch("no storage needed");
	}
#endif
	symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols");

	number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
     
	if (number_of_symbols < 0) {
	    barf("can't canonicalise symbol table");
	}

        for( i = 0; i != number_of_symbols; ++i ) {
            symbol_info info;
            bfd_get_symbol_info(abfd,symbol_table[i],&info);
            /*debugBelch("\t%c\t0x%x      \t%s\n",info.type,(nat)info.value,info.name); */
            if (isReal(info.type, info.name)) {
                num_real_syms += 1;
            }
        }
    
        IF_DEBUG(interpreter,
                 debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", 
                         number_of_symbols, num_real_syms)
                 );

        reset_table( num_real_syms );
    
        for( i = 0; i != number_of_symbols; ++i ) {
            symbol_info info;
            bfd_get_symbol_info(abfd,symbol_table[i],&info);
            if (isReal(info.type, info.name)) {
                insert( info.value, info.name );
            }
        }

        stgFree(symbol_table);
    }
    prepare_table();
}
コード例 #6
0
int DateTest(int, char*[])
{
  try
  {
    auto config = std::make_shared<sql::connection_config>();

#ifdef WIN32
	config->dbname = "test";
	config->user = "******";
	config->password = "******";
	config->debug = true;
#else
    // TODO: assume there is a DB with the "username" as a name and the current user has "peer" access rights
    config->dbname = getenv("USER");
    config->user = config->dbname;
    config->debug = true;
#endif

    sql::connection db(config);

    for (int i = 0; i <= 1; ++i)
    {
      if (i)
        std::cerr << "Testing date/time WITH timezone\n";
      else
        std::cerr << "Testing date/time WITHOUT timezone\n";
      prepare_table(db, i);

      const auto tab = TabDateTime{};
      db(insert_into(tab).default_values());
      for (const auto& row: db(select(all_of(tab)).from(tab).unconditionally()))
      {
        require_equal(__LINE__, row.colDayPoint.is_null(), true);
        require_equal(__LINE__, row.colDayPoint.value(), ::sqlpp::chrono::day_point{});
        require_equal(__LINE__, row.colTimePoint.is_null(), true);
        require_equal(__LINE__, row.colTimePoint.value(), ::sqlpp::chrono::microsecond_point{});
      }

      db(update(tab).set(tab.colDayPoint = today, tab.colTimePoint = now).unconditionally());

      for (const auto& row: db(select(all_of(tab)).from(tab).unconditionally()))
      {
         require_equal(__LINE__, row.colDayPoint.value(), today);
         require_equal(__LINE__, row.colTimePoint.value(), now);
      }

      db(update(tab).set(tab.colDayPoint = yesterday, tab.colTimePoint = today).unconditionally());

      for (const auto& row: db(select(all_of(tab)).from(tab).unconditionally()))
      {
         require_equal(__LINE__, row.colDayPoint.value(), yesterday);
         require_equal(__LINE__, row.colTimePoint.value(), today);
      }

      auto prepared_update = db.prepare(
              update(tab).set(tab.colDayPoint = parameter(tab.colDayPoint), tab.colTimePoint = parameter(tab.colTimePoint))
                .unconditionally());
      prepared_update.params.colDayPoint = today;
      prepared_update.params.colTimePoint = now;
      std::cout << "---- running prepared update ----" << std::endl;
      db(prepared_update);
      std::cout << "---- finished prepared update ----" << std::endl;

      for (const auto& row: db(select(all_of(tab)).from(tab).unconditionally()))
      {
         require_equal(__LINE__, row.colDayPoint.value(), today);
         require_equal(__LINE__, row.colTimePoint.value(), now);
      }
    }
  } catch (std::exception& e)
  {
    std::cerr << "Exception: " << e.what() << std::endl;
    return 1;
  }
  catch (...)
  {
    std::cerr << "Unknown exception" << std::endl;
    return 1;
  }
  return 0;
}