DBConnection *DBConnection_new(char *host, char *user, char *pass, char *dbname, unsigned int port) { DBConnection *dbc; MYSQL *mysql; if ((dbc = (DBConnection *)calloc(1,sizeof(DBConnection))) == NULL) { Error_write(ECALLERR,"DBConnection_new",ERR_SEVERE,"dbc"); return NULL; } if ((mysql = mysql_init(NULL)) == NULL) { Error_write(EMYSQLCONN, "DBConnection_new", ERR_SEVERE, " failed creating mysql object in mysql_init, mysql error %s",mysql_error(mysql)); return NULL; } /* on unix, localhost will connect via a local socket by default and ignore the port. If the * user has specified a port then force mysql to use it by setting the protocol to TCP (this is * necessary if using ssh tunnels). */ if (mysql && host && port && !strcmp(host, "localhost")) { const enum mysql_protocol_type arg = MYSQL_PROTOCOL_TCP ; mysql_options(mysql, MYSQL_OPT_PROTOCOL, &arg) ; } if ((mysql_real_connect(mysql,host, user, pass, dbname, port, NULL, 0)) == NULL) { Error_write(EMYSQLCONN, "DBConnection_new", ERR_SEVERE, " dbname %s (host %s user %s pass %s port %d), mysql error %s", dbname,host,user,pass,port,mysql_error(mysql)); return NULL; } EcoString_copyStr(ecoSTable, &(dbc->host), host, 0); EcoString_copyStr(ecoSTable, &(dbc->user), user, 0); if (pass) EcoString_copyStr(ecoSTable, &(dbc->pass), pass, 0); EcoString_copyStr(ecoSTable, &(dbc->dbName), dbname, 0); dbc->port = port; dbc->mysql = mysql; dbc->prepare = DBConnection_prepare; if (!dbc->host || !dbc->user || !dbc->dbName || (pass && !dbc->pass)) { Error_trace("DBConnnection_new",NULL); return NULL; } return dbc; }
ECOSTRING RawContig_setName(RawContig *rc, char *name) { if (!EcoString_copyStr(ecoSTable,&(rc->name),name,0)) { fprintf(stderr,"ERROR: Failed allocating space for contig name\n"); return NULL; } return rc->name; }
ECOSTRING Sequence_setName(Sequence *seq, char *name) { if (EcoString_copyStr(ecoSTable,&(seq->name),name,0)) { fprintf(stderr,"ERROR: Failed allocating space for seq name\n"); return NULL; } return seq->name; }
ECOSTRING PredictionExon_setDisplayLabel(PredictionExon *pe, char *label) { EcoString_copyStr(ecoSTable, &(pe->displayLabel), label, 0); return pe->displayLabel; }
ECOSTRING SyntenyRegion_setSeqType(SyntenyRegion *sr, char *seqType) { EcoString_copyStr(ecoSTable, &(sr->seqType), seqType, 0); return sr->seqType; }
ECOSTRING SyntenyRegion_setHitChrName(SyntenyRegion *sr, char *hitChrName) { EcoString_copyStr(ecoSTable, &(sr->hitChrName), hitChrName, 0); return sr->hitChrName; }
ECOSTRING PredictionTranscript_setType(PredictionTranscript *t, char *type) { EcoString_copyStr(ecoSTable,&(t->type),type,0); return t->type; }
ECOSTRING PredictionTranscript_setDisplayLabel(PredictionTranscript *pt, char *label) { EcoString_copyStr(ecoSTable, &(pt->displayLabel), label, 0); return pt->displayLabel; }
ECOSTRING SimpleFeature_setDisplayLabel(SimpleFeature *sf, char *label) { EcoString_copyStr(ecoSTable, &(sf->displayLabel), label, 0); return sf->displayLabel; }
CoordSystem *CoordSystem_new(char *name, char *version, int rank, IDType dbID, CoordSystemAdaptor *csa, int isDefault, int isSeqLevel, int isTopLevel) { if (version == NULL) { version = emptyString; } isTopLevel = isTopLevel ? 1 : 0; isSeqLevel = isSeqLevel ? 1 : 0; isDefault = isDefault ? 1 : 0; if ( isTopLevel == 1 ) { if ( rank != 0 ) { fprintf(stderr,"RANK argument must be 0 if TOP_LEVEL is 1"); exit(1); } if ( name != NULL ) { if ( strcmp(name,"toplevel")) { fprintf(stderr,"The NAME argument must be 'toplevel' if TOP_LEVEL is 1"); exit(1); } } else { name="toplevel"; } if ( isSeqLevel == 1 ) { fprintf(stderr,"SEQUENCE_LEVEL argument must be 0 if TOP_LEVEL is 1"); exit(1); } isDefault = 0; } else { if ( rank == 0 ) { fprintf(stderr,"RANK argument must be non-zero unless TOP_LEVEL is 1"); exit(1); } if ( name == NULL ) { fprintf(stderr,"The NAME argument is required"); exit(1); } else if ( !strcmp(name,"toplevel")) { fprintf( stderr, "Cannot name coord system 'toplevel unless TOP_LEVEL is 1" ); exit(1); } } if ( rank < 0 ) { fprintf(stderr, "The RANK argument must be a non negative integer"); exit(1); } CoordSystem *cs; if ((cs = (CoordSystem *)calloc(1,sizeof(CoordSystem))) == NULL) { fprintf(stderr,"ERROR: Failed allocating space for cs\n"); return NULL; } cs->objectType = CLASS_COORDSYSTEM; cs->funcs = &coordSystemFuncs; EcoString_copyStr(ecoSTable,&(cs->version),version,0); EcoString_copyStr(ecoSTable,&(cs->name),name,0); cs->isTopLevel = isTopLevel; cs->isSeqLevel = isSeqLevel; cs->isDefaultVersion = isDefault; cs->rank = rank; CoordSystem_setAdaptor(cs, (BaseAdaptor *)csa); CoordSystem_setDbID(cs, dbID); return cs; }