Exemple #1
0
void
caja_column_chooser_get_settings (CajaColumnChooser *chooser,
                                  char ***visible_columns,
                                  char ***column_order)
{
    g_return_if_fail (CAJA_IS_COLUMN_CHOOSER (chooser));
    g_return_if_fail (visible_columns != NULL);
    g_return_if_fail (column_order != NULL);

    *visible_columns = get_column_names (chooser, TRUE);
    *column_order = get_column_names (chooser, FALSE);
}
void
nautilus_column_chooser_get_settings (NautilusColumnChooser *chooser,
				      char ***visible_columns,
				      char ***column_order)
{
	g_return_if_fail (NAUTILUS_IS_COLUMN_CHOOSER (chooser));
	g_return_if_fail (visible_columns != NULL);
	g_return_if_fail (column_order != NULL);

	*visible_columns = get_column_names (chooser, TRUE);
	*column_order = get_column_names (chooser, FALSE);
}
SQLRETURN CLMoreResults( SQLHSTMT statement_handle )
{
    CLHSTMT cl_statement = (CLHSTMT) statement_handle; 
	SQLRETURN ret;

    ret = SQLMORERESULTS( cl_statement -> cl_connection,
            cl_statement -> driver_stmt );

    if ( SQL_SUCCEEDED( ret ))
    {
        SQLSMALLINT column_count;

        ret = SQLNUMRESULTCOLS( cl_statement -> cl_connection,
           cl_statement -> driver_stmt,
           &column_count );

        cl_statement -> column_count = column_count;
        cl_statement -> first_fetch_done = 0;

        if ( column_count > 0 )
        {
            ret = get_column_names( cl_statement );
        }
    }

	return ret;
}
Exemple #4
0
size_t
O2DatDB::
select(const wchar_t *sql, SQLResultList &out)
{
#if TRACE_SQL_EXEC_TIME
	stopwatch sw("select");
#endif
	wstrarray cols;

	sqlite3 *db = NULL;
	int err = sqlite3_open16(dbfilename.c_str(), &db);
	if (err != SQLITE_OK)
		goto error;
	sqlite3_busy_timeout(db, 5000);

	sqlite3_stmt *stmt = NULL;
	err = sqlite3_prepare16_v2(db, sql, wcslen(sql)*2, &stmt, NULL);
	if (err != SQLITE_OK)
		goto error;
	sqlite3_reset(stmt);

	err = sqlite3_step(stmt);
	if (err != SQLITE_ROW && err != SQLITE_DONE)
		goto error;

	if (out.empty()) {
		//一行目
		cols.clear();
		get_column_names(stmt, cols);
		out.push_back(cols);
		cols.clear();
		get_columns(stmt, cols);
		out.push_back(cols);
	}
	while (sqlite3_step(stmt) == SQLITE_ROW) {
		//2行目以降
		cols.clear();
		get_columns(stmt, cols);
		out.push_back(cols);
	}

	sqlite3_finalize(stmt);
	stmt = NULL;

	err = sqlite3_close(db);
	if (err != SQLITE_OK)
		goto error;

	return (out.size());

error:
	log(db);
	if (stmt) sqlite3_finalize(stmt);
	if (db) sqlite3_close(db);
	return (0);
}
Exemple #5
0
 void create_cluster() {
   Attribute::register_class_names(get_column_names());
   Record * r = make_quuxalot_record();
   ClusterHead ch(r, 0.9953);
   RecordPList rl = get_record_list();
   cBlocking_Operation_By_Coauthors  blocker_coauthor = get_blocker_coathor();
   Cluster::set_reference_patent_tree_pointer( blocker_coauthor.get_patent_tree());
   Cluster * c = new Cluster(ch, rl);
   delete c;
 }
SQLRETURN CLExecDirect( SQLHSTMT statement_handle,
           SQLCHAR *statement_text,
           SQLINTEGER text_length )
{
    CLHSTMT cl_statement = (CLHSTMT) statement_handle; 
    SQLRETURN ret;

    /*
     * save the statement for later use
     */

    if ( cl_statement -> sql_text )
    {
        free( cl_statement -> sql_text );
    }
    if ( text_length < 0 )
    {
        cl_statement -> sql_text = strdup((char*) statement_text );
    }
    else
    {
        cl_statement -> sql_text = malloc( text_length + 1 );
        memcpy( cl_statement -> sql_text, statement_text, text_length );
        cl_statement -> sql_text[ text_length ] = '\0';
    }

    ret = SQLEXECDIRECT( cl_statement -> cl_connection,
           cl_statement -> driver_stmt,
           statement_text,
           text_length );

    if ( SQL_SUCCEEDED( ret ))
    {
        SQLSMALLINT column_count;

        ret = SQLNUMRESULTCOLS( cl_statement -> cl_connection,
           cl_statement -> driver_stmt,
           &column_count );

        cl_statement -> column_count = column_count;
        cl_statement -> first_fetch_done = 0;

        if ( column_count > 0 )
        {
            ret = get_column_names( cl_statement );
        }
    }

    return ret;
}
Exemple #7
0
 // tests if the columns of TSDB 'table' match the datapoint type T
 // returns false if 'table' does not have the columns necessary for required datatype
 template<typename T> bool _columns_match_type(const std::string& table)
 {
     BOOST_STATIC_ASSERT((boost::is_base_of< dp::DataPoint, T>::value));
     
     std::vector<std::string> columns = get_column_names( table );
     std::vector<std::string> t_columns = dp::dp_names<T>();
     
     std::sort(columns.begin(),columns.end());
     std::sort(t_columns.begin(),t_columns.end());
     
     if( !includes(columns.begin(), columns.end(), t_columns.begin(), t_columns.end() ) )
         return false;
     
     return true;
 }
SQLRETURN CLColumnPrivileges(
    SQLHSTMT            statement_handle,
    SQLCHAR             *catalog_name,
    SQLSMALLINT         name_length1,
    SQLCHAR             *schema_name,
    SQLSMALLINT         name_length2,
    SQLCHAR             *table_name,
    SQLSMALLINT         name_length3,
    SQLCHAR             *column_name,
    SQLSMALLINT         name_length4 )
{
    CLHSTMT cl_statement = (CLHSTMT) statement_handle; 
    SQLRETURN ret;

    ret = SQLCOLUMNPRIVILEGES( cl_statement -> cl_connection,
            cl_statement -> driver_stmt,
            catalog_name,
            name_length1,
            schema_name,
            name_length2,
            table_name,
            name_length3,
            column_name,
            name_length4 );

    if ( SQL_SUCCEEDED( ret ))
    {
        SQLSMALLINT column_count;

        ret = SQLNUMRESULTCOLS( cl_statement -> cl_connection,
           cl_statement -> driver_stmt,
           &column_count );

        cl_statement -> column_count = column_count;
        cl_statement -> first_fetch_done = 0;
        cl_statement -> not_from_select = 1;

        if ( column_count > 0 )
        {
            ret = get_column_names( cl_statement );
        }
    }
    return ret;
}
SQLRETURN CLPrimaryKeys(
    SQLHSTMT           statement_handle,
    SQLCHAR            *sz_catalog_name,
    SQLSMALLINT        cb_catalog_name,
    SQLCHAR            *sz_schema_name,
    SQLSMALLINT        cb_schema_name,
    SQLCHAR            *sz_table_name,
    SQLSMALLINT        cb_table_name )
{
    CLHSTMT cl_statement = (CLHSTMT) statement_handle; 
    SQLRETURN ret;

    ret = SQLPRIMARYKEYS( cl_statement -> cl_connection,
            cl_statement -> driver_stmt,
            sz_catalog_name,
            cb_catalog_name,
            sz_schema_name,
            cb_schema_name,
            sz_table_name,
            cb_table_name );

    if ( SQL_SUCCEEDED( ret ))
    {
        SQLSMALLINT column_count;

        ret = SQLNUMRESULTCOLS( cl_statement -> cl_connection,
           cl_statement -> driver_stmt,
           &column_count );

        cl_statement -> column_count = column_count;
        cl_statement -> first_fetch_done = 0;
        cl_statement -> not_from_select = 1;

        if ( column_count > 0 )
        {
            ret = get_column_names( cl_statement );
        }
    }
    return ret;
}
void extract_sequences(char vcf_filename[], char tree_filename[],char multi_fasta_filename[],int min_snps, char original_multi_fasta_filename[])
{
	FILE *vcf_file_pointer;
	vcf_file_pointer=fopen(vcf_filename, "r");
	
	newick_node* root_node;
	int number_of_snps;
	int number_of_columns;
	int i;
	int length_of_original_genome;
	length_of_original_genome = genome_length(original_multi_fasta_filename);	
	
	number_of_columns = get_number_of_columns_from_file(vcf_file_pointer);
	char* column_names[number_of_columns];
	for(i = 0; i < number_of_columns; i++)
	{
		column_names[i] = calloc(MAX_SAMPLE_NAME_SIZE,sizeof(char));
	}
	get_column_names(vcf_file_pointer, column_names, number_of_columns);
	
	number_of_snps  = number_of_snps_in_phylip();
	
	int snp_locations[number_of_snps];
	
	get_integers_from_column_in_vcf(vcf_file_pointer, snp_locations, number_of_snps, column_number_for_column_name(column_names, "POS", number_of_columns));

	root_node = build_newick_tree(tree_filename, vcf_file_pointer,snp_locations, number_of_snps, column_names, number_of_columns, length_of_original_genome,min_snps);
	fclose(vcf_file_pointer);

	int filtered_snp_locations[number_of_snps];
	int number_of_filtered_snps;
	int number_of_samples = number_of_samples_from_parse_phylip();

	char * sample_names[number_of_samples];
  get_sample_names_from_parse_phylip(sample_names);

  char * reference_sequence_bases;
  reference_sequence_bases = (char *) calloc((number_of_snps+1),sizeof(char));

	get_sequence_for_sample_name(reference_sequence_bases, sample_names[0]);
	int internal_nodes[number_of_samples];
	int a = 0;
	for(a =0; a < number_of_samples; a++)
	{
		internal_nodes[a] = get_internal_node(a);
	}

	number_of_filtered_snps = refilter_existing_snps(reference_sequence_bases, number_of_snps, snp_locations, filtered_snp_locations,internal_nodes);
	char * filtered_bases_for_snps[number_of_filtered_snps];

	filter_sequence_bases_and_rotate(reference_sequence_bases, filtered_bases_for_snps, number_of_filtered_snps);
	
	create_phylip_of_snp_sites(tree_filename, number_of_filtered_snps, filtered_bases_for_snps, sample_names, number_of_samples,internal_nodes);
	create_vcf_file(tree_filename, filtered_snp_locations, number_of_filtered_snps, filtered_bases_for_snps, sample_names, number_of_samples,internal_nodes,0);
	create_fasta_of_snp_sites(tree_filename, number_of_filtered_snps, filtered_bases_for_snps, sample_names, number_of_samples,internal_nodes);
	
	// Create an new tree with updated distances
	scale_branch_distances(root_node, number_of_filtered_snps);

	FILE *output_tree_pointer;
	output_tree_pointer=fopen(tree_filename, "w");
	print_tree(root_node,output_tree_pointer);
	fprintf(output_tree_pointer,";");
	fflush(output_tree_pointer);
	fclose(output_tree_pointer);
	
	
	// Theres a seg fault in here
	for(i = 0; i < number_of_columns; i++)
	{
		free(column_names[i] );
	}
	
	for(i=0; i<number_of_samples; i++ )
	{
		free(sample_names[i]);
	}
	
	for(i=0; i<number_of_filtered_snps; i++ )
	{
		free(filtered_bases_for_snps[i]);
	}
	cleanup_node_memory(root_node);
	seqFreeAll();
	free(reference_sequence_bases);
}
Exemple #11
0
	int main_i(const std::vector<std::string> &argv)
	{
		int argc = argv.size();
		if (argc == 1 || (argc == 2 && argv[1] == "-h")) {
			std:: cout << "Picosel ver. 1.5 (C) 2009-2010 AIST" "\n"
				"Usage 1: picosel OPTION from inputfile select column where EXPRESSION" "\n"
				"Usage 2: picosel OPTION from inputfile select column order by column" "\n"
				"Option" "\n"
				"  -o outputfile: specify output file." "\n";
			return 0;
		}

		if (argc == 3 && argv[1] == "--text") {
			return convert_binary_file_to_text(argv[2]);
		}

		int r = analyze_commandline(argv);
		if (r != 0) {
			return r;
		}

		std:: ifstream input;
		input.open(fromFile.c_str(), std:: ios::in | std:: ios::binary);
		if (! input.is_open()) {
			std:: cerr << "error: can not open file '" << fromFile << "'" << std:: endl;
			return 1;
		}
		std:: istream *pInput = &input;

		r = get_column_names(pInput);
		if (r != 0) {
			return r;
		}
		
		int selectColIndex = findNamedColumn(selectCol);
		if (selectColIndex == -1) {
			std:: cerr << "error: unknown column name '" << selectCol << "'" << std:: endl;
			return 1;
		}

		r = check_expression();
		if (r != 0) {
			return r;
		}

		std:: ostream *pOutput = &std:: cout;
		std:: ofstream output;
		if (! outputFile.empty()) {
			output.open(outputFile.c_str(), binaryOutputFactor != 0 ? (std:: ios::out | std:: ios::binary) : std:: ios::out);
			if (! output.is_open()) {
				std:: cerr << "error: can not create file '" << outputFile << "'" << std:: endl;
				return 1;
			}
			pOutput = &output;
		}

		if (! orderByAsc.empty()) {
			int orderColIndex = findNamedColumn(orderByAsc);
			if (orderColIndex == -1) {
				std:: cerr << "error: unknown column name '" << orderByAsc << "'" << std:: endl;
				return 1;
			}
			r = do_sorting(pInput, pOutput, selectColIndex, orderColIndex, 1/* asc */, outputFile);
		}
		else if (! orderByDesc.empty()) {
			int orderColIndex = findNamedColumn(orderByDesc);
			if (orderColIndex == -1) {
				std:: cerr << "error: unknown column name '" << orderByDesc << "'" << std:: endl;
				return 1;
			}
			r = do_sorting(pInput, pOutput, selectColIndex, orderColIndex, -1/* desc */, outputFile);
		}
		else {
			r = do_selecting(pInput, pOutput, selectColIndex);
		}

		output.close();
		input.close();

		return r;
	}