void ed_nip_renz_info(int seq_num,
		      ed_renz_res *data,
		      int start,
		      int print_opt)
{
    int seq_len;
    char *seq;
    int sequence_type;
    
    seq = GetEdenSeq(seq_num);
    seq_len = GetEdenLength(seq_num);
    /*sequence_type = GetSequenceStructure(seq_num);*/
    sequence_type = GetEdenType(seq_num);

    vfuncheader("Restriction enzymes result list");
    
    vmessage("Sequence %s\n", GetEdenName(seq_num));

    vmessage("Number of enzymes = %d\n", data->num_enzymes);
    vmessage("Number of matches = %d\n", data->num_match);

    if (print_opt == 0) {
	start_message();
	EdPrintEnzymeByEnzyme(data->r_enzyme, data->match, data->num_match, 
			      data->num_enzymes, seq, seq_len, 
			      sequence_type, start);
	end_message(data->re_win);
    } else {
	start_message();
	EdOrderOnPosition(data->r_enzyme, data->match, data->num_match,
			seq, seq_len, sequence_type, start);
	end_message(data->re_win);
    }
}
Example #2
0
// Main function
int main() {
    int num_day, ans, weather_value, score = 0, completed = FALSE;
    int dragon_strength, dragon_intelligence, dragon_agility;
    
    char name[20], answer[4];
    
    srand(time(0));
    
    printf("Welcome to Dragon Training!\n");
    printf("You've been assigned a new dragon! Would you like to give it a name? (yes/no)\n");
    scanf("%s", answer);
    
    if(strcmp(answer, "yes") == 0) {
        printf("Great! What would like to call your dragon?\n");
        scanf("%s", name);
    }
    else
        strcpy(name, "your dragon");
    
    printf("\nTo complete training, %s must finish the final \nobstacle course with a score of 70 or better.\n", name);
    printf("\nYou may attempt the obstacle course at any time, \nbut you must finish within 10 days.\n");
    printf("\nBetter get started!\n");
    
    set_stats(&dragon_strength, &dragon_intelligence, &dragon_agility);
    
    for (num_day = 1; num_day <= 10; num_day++) {
        printf("\nIt is Day #%d.\n", num_day);
        print_stats(dragon_strength, dragon_intelligence, dragon_agility, name);
        weather_value = weather();
        ans = menu();
        
        switch(ans) {
            case 1:
                dragon_strength += train_strength(weather_value, name);
                break;
            case 2:
                dragon_intelligence += train_intelligence(weather_value, name);
                break;
            case 3:
                dragon_agility += train_agility(weather_value, name);
                break;
            case 4:
                score = obstacle_course(weather_value, dragon_strength, dragon_intelligence, dragon_agility);
                printf("%s scored a %d on their obstacle course run!\n", name, score);
                break;
        }
        
        if(score >= SCORE) {
            completed = TRUE;
            break;
        }
    }
    
    end_message(completed, name);
    
    return 0;
}
Example #3
0
/**
 * Shut down GOSS communication
 */
void gridpack::goss::GOSSUtils::terminateGOSS()
{
  if (GA_Nodeid()==0) {
    char topic[128];

#ifndef GOSS_DEBUG
    Connection *connection;
    Session *session;
    Destination *destination;
    MessageProducer *producer;


    std::auto_ptr<ActiveMQConnectionFactory>
      connectionFactory(new ActiveMQConnectionFactory(p_URI)) ;
    // Create a Connection
    connection = connectionFactory->createConnection(p_username, p_passwd);
    connection->start();

    // Create a Session
    session = connection->createSession(Session::AUTO_ACKNOWLEDGE);

    // Create the destination (Topic or Queue)
    sprintf(topic,"topic/goss/gridpack/close_goss");
    destination = session->createTopic(topic);

    // Create a MessageProducer from the Session to the Topic
    producer = session->createProducer(destination);
    producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT);

    // Send final message indicating that channel is being close
    std::string buf = "Closing GOSS";
    std::auto_ptr<TextMessage>
      end_message(session->createTextMessage(buf));
    producer->send(end_message.get());
    if (connection) delete connection;
    if (session) delete session;
    if (destination) delete destination;
    if (producer) delete producer;
#endif
  }
}
Example #4
0
/*
 * Match callback.
 * 'obj' is a match contained within the check assembly list.
 */
void *checkass_obj_func(int job, void *jdata, obj_checkass *obj,
			mobj_checkass *ca) {
    static char buf[80];
    obj_cs *cs;
    int cs_id;

    cs_id = type_to_result(ca->io, REG_TYPE_CONTIGSEL, 0);
    cs = result_data(ca->io, cs_id);

    switch(job) {
    case OBJ_LIST_OPERATIONS:
	return "Information\0Hide\0Invoke contig editor *\0"
	    "SEPARATOR\0Remove\0";

    case OBJ_INVOKE_OPERATION:
	switch(*((int *)jdata)) {
	case 0: /* Information */
	    vfuncgroup(1, "2D plot matches");
	case -1: /* Information from results manager */
	    start_message();
	    vmessage("check_assembly match:\n");
	    vmessage("    From contig %s(#%"PRIrec") at %d\n",
		     get_contig_name(ca->io, ABS(obj->c1)),
		     io_clnbr(ca->io, ABS(obj->c1)), obj->pos1);
	    vmessage("    With contig %s(#%"PRIrec") at %d\n",
		     get_contig_name(ca->io, ABS(obj->c2)),
		     io_clnbr(ca->io, ABS(obj->c2)), obj->pos2);
	    vmessage("    Length %d, mismatch %2.2f%%\n\n",
		     obj->length, ((float)obj->score)/10000);
	    end_message(cs->window);
	    break;

	case 1: /* Hide */
	    obj_hide(GetInterp(), cs->window, obj,
		     (mobj_repeat *)ca, csplot_hash);
	    break;

	case -2: /* default */
	case 2: /* Invoke contig editor */ {
	    tg_rec cnum, llino;
	    int pos;

	    obj->flags |= OBJ_FLAG_VISITED;
	    ca->current = obj - ca->match;
	    Tcl_VarEval(GetInterp(), "CSLastUsed ", CPtr2Tcl(ca), NULL);

	    cnum  = abs(obj->c1);
	    llino = obj->read;
	    pos   = obj->pos1 - io_relpos(ca->io, llino);
	    if (pos < 1)
		pos = 1;
	    if (pos > ABS(io_length(ca->io, llino)))
		pos = ABS(io_length(ca->io, llino));

//	    if ((id = editor_available(cnum, 1)) != -1) {
//		move_editor(id, llino, pos);
//	    } else {
		edit_contig(ca->io, cnum, llino, pos);
//	    }
	    break;
	}

	case 3: /* Remove */
	    obj_remove(GetInterp(), cs->window, obj,
		       (mobj_repeat *)ca, csplot_hash);
	    break;

        }
        break;

    case OBJ_GET_BRIEF:
	sprintf(buf,
		"check_assembly: #%"PRIrec"@%d len %d, mis %2.2f%%",
		obj->read, obj->pos1, obj->length, ((float)obj->score)/10000);
	return buf;
    }

    return NULL;
}
Example #5
0
/**
 * Initialize goss bus specifying all topics that will be used in this
 * application. This must be called on the world communicator.
 * @param topics list of topics that will be sent by the application
 * @param URI channel URI
 * @param username server username
 * @param passwd server password
 */
void gridpack::goss::GOSSUtils::initGOSS(std::vector<std::string> &topics,
    const char *URI, const char* username, const char *passwd)
{
  char sbuf[128];
  int nvals = topics.size();
  int i;
  // Store channel parameters
  p_URI = URI;
  p_username = username;
  p_passwd = passwd;

  // Concatenate topics into a single string
  if (topics.size() == 0) {
    printf("No topics provided when initializing GOSSUtils\n");
  }
  std::string list = topics[0];
  if (nvals > 0) {
    list = topics[0];
    for (i=1; i<nvals; i++) {
      sprintf(sbuf," %s",topics[i].c_str());
      list.append(sbuf);
    }
  }

  // Send string using topic "topic/goss/gridpack"
  if (GA_Nodeid()==0) {
    char topic[128];

#ifndef GOSS_DEBUG
    Connection *connection;
    Session *session;
    Destination *destination;
    MessageProducer *producer;


    std::auto_ptr<ActiveMQConnectionFactory>
      connectionFactory(new ActiveMQConnectionFactory(p_URI)) ;
    // Create a Connection
    connection = connectionFactory->createConnection(p_username, p_passwd);
    connection->start();

    // Create a Session
    session = connection->createSession(Session::AUTO_ACKNOWLEDGE);
#endif

    // Create the destination (Topic or Queue)
    sprintf(topic,"topic/goss/gridpack/topic_list");
    //destination = session->createQueue(topic);
    printf("topic = %s\n", topic);
#ifndef GOSS_DEBUG
    destination = session->createTopic(topic);

    // Create a MessageProducer from the Session to the Topic
    producer = session->createProducer(destination);
    producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT);

    // Send topics
    std::auto_ptr<TextMessage> message_dat(
        session->createTextMessage(list));
#endif
    printf("list: %s\n", list.c_str());
#ifndef GOSS_DEBUG
    producer->send(message_dat.get());
#endif
    // Close data connection
    // Send final message indicating that channel is being close
    std::string buf = "Closing channel";
#ifndef GOSS_DEBUG
    std::auto_ptr<TextMessage>
      end_message(session->createTextMessage(buf));
    producer->send(end_message.get());
    std::string acknowledge_topic("topic.goss.gridpack.acknowledge");
    std::auto_ptr<Destination> dest(session->createTopic(acknowledge_topic));
    std::auto_ptr<MessageConsumer> consumer(session->createConsumer(dest.get()));
    std::cout << "Waiting for messages..."<<std::endl;

    std::auto_ptr<Message> message(consumer->receive());
    const TextMessage *txtMsg = dynamic_cast<const TextMessage*>(message.get());
    if (txtMsg->getText() != "success") {
      std::cout << "Message failure: "<<txtMsg->getText()<<std::endl;
    }

    if (connection) delete connection;
    if (session) delete session;
    if (destination) delete destination;
    if (producer) delete producer;
#endif
  }
  gridpack::parallel::Communicator world;
  world.barrier();
}
Example #6
0
/*
 * Match callback.
 * 'obj' is a match contained within the 'repeat' list.
 */
void *repeat_obj_func(int job, void *jdata, obj_match *obj,
		      mobj_repeat *repeat) {
    static char buf[80];
    obj_cs *cs;
    int cs_id;

    cs_id = type_to_result(repeat->io, REG_TYPE_CONTIGSEL, 0);
    cs = result_data(repeat->io, cs_id, 0);

    switch(job) {
    case OBJ_LIST_OPERATIONS:
	if (io_rdonly(repeat->io) && ((obj->c1 > 0 && obj->c2 < 0) ||
				      (obj->c1 < 0 && obj->c2 > 0))) {
	    return "Information\0Hide\0IGNORE\0"
		"IGNORE\0SEPARATOR\0Remove\0";
	} else {
	    return "Information\0Hide\0Invoke join editor *\0"
		"Invoke contig editors\0SEPARATOR\0Remove\0";
	}

    case OBJ_INVOKE_OPERATION:
	switch(*((int *)jdata)) {
	case 0: /* Information */
	    vfuncgroup(1, "2D plot matches");
	case -1: /* Information from results manager */
	    start_message();
	    vmessage("Repeat match (%s)\n",
		     ((obj->c1 > 0) == (obj->c2 > 0)) ? "direct" : "inverted");
	    vmessage("    From contig %s(#%d) at %d\n",
		     get_contig_name(repeat->io, ABS(obj->c1)),
		     io_clnbr(repeat->io, ABS(obj->c1)), obj->pos1);
	    vmessage("    With contig %s(#%d) at %d\n",
		     get_contig_name(repeat->io, ABS(obj->c2)),
		     io_clnbr(repeat->io, ABS(obj->c2)), obj->pos2);
	    vmessage("    Length %d\n\n", obj->length);
	    end_message(cs->window);
	    break;

	case 1: /* Hide */
	    obj_hide(GetInterp(), cs->window, obj,
		     (mobj_repeat *)repeat, csplot_hash);
	    break;

	case -2: /* default */
	case 2: /* Invoke join editor */ {
	    int cnum[2], llino[2], pos[2];

	    obj->flags |= OBJ_FLAG_VISITED;
	    repeat->current = obj - repeat->match;
	    Tcl_VarEval(GetInterp(), "CSLastUsed ", CPtr2Tcl(repeat), NULL);

	    cnum[0] = ABS(obj->c1);
	    cnum[1] = ABS(obj->c2);

	    /* Complement a contig if needed */
	    if ((obj->c1 > 0) != (obj->c2 > 0)) {
		if (cnum[0] == cnum[1]) {
		    verror(ERR_WARN, "join_editor",
			   "cannot display the same contig in two "
			   "different orientations");
		    break;
		}
		if (io_rdonly(repeat->io)) {
		    bell();
		    break;
		}

		if (io_clength(repeat->io, ABS(obj->c1)) <
		    io_clength(repeat->io, ABS(obj->c2))) {
		    if (-1 == complement_contig(repeat->io, ABS(obj->c1)))
			if (-1 == complement_contig(repeat->io, ABS(obj->c2)))
			    return NULL;
		} else {
		    if (-1 == complement_contig(repeat->io, ABS(obj->c2)))
			if (-1 == complement_contig(repeat->io, ABS(obj->c1)))
			    return NULL;
		}
	    }

	    /*
	     * NB: obj->pos1 now may not be the same value as when this
	     * function was entered, due to the complementing!
	     */
	    pos[0] = obj->pos1;
	    pos[1] = obj->pos2;

	    llino[0] = io_clnbr(repeat->io, cnum[0]);
	    llino[1] = io_clnbr(repeat->io, cnum[1]);

	    join_contig(GetInterp(), repeat->io, cnum, llino, pos,
			consensus_cutoff, quality_cutoff);
	    break;
	}

	case 3: /* Invoke contig editors */ {
	    int cnum, llino, pos;

	    cnum  = ABS(obj->c1);
	    llino = io_clnbr(repeat->io, cnum);
	    pos   = obj->pos1;

	    edit_contig(GetInterp(), repeat->io, cnum, llino, pos,
			consensus_cutoff, quality_cutoff, 0, NULL);

	    cnum  = ABS(obj->c2);
	    llino = io_clnbr(repeat->io, cnum);
	    pos   = obj->pos2;

	    edit_contig(GetInterp(), repeat->io, cnum, llino, pos,
			consensus_cutoff, quality_cutoff, 0, NULL);
	    break;
	}

	case 4: /* Remove */
	    obj_remove(GetInterp(), cs->window, obj,
		     (mobj_repeat *)repeat, csplot_hash);
	    break;

	}
	break;

    case OBJ_GET_BRIEF:
	sprintf(buf, "Repeat: %c#%d@%d with %c#%d@%d, len %d",
		obj->c1 > 0 ? '+' : '-',
		io_clnbr(repeat->io, ABS(obj->c1)), obj->pos1,
		obj->c2 > 0 ? '+' : '-',
		io_clnbr(repeat->io, ABS(obj->c2)), obj->pos2,
		obj->length);
	return buf;
    }

    return NULL;
}
Example #7
0
/*
 * functions to act upon matches generated using TAGs
 */
void *find_oligo_obj_func1(int job,
			  void *jdata,
			  obj_match *obj,
			  mobj_find_oligo *find_oligo)
{
    static char buf[80];
    obj_cs *cs;
    int cs_id;

    cs_id = type_to_result(find_oligo->io, REG_TYPE_CONTIGSEL, 0);
    cs = result_data(find_oligo->io, cs_id);

    switch(job) {
    case OBJ_LIST_OPERATIONS:
	return "Information\0Hide\0Invoke join editor *\0"
	    "Invoke contig editors\0SEPARATOR\0Remove\0";

    case OBJ_INVOKE_OPERATION:
	switch(*((int *)jdata)) {
	case 0: /* Information */
	    vfuncgroup(1, "2D plot matches");
	case -1: /* Information from results manager */

	    start_message();
	    vmessage("Sequence search:\n");
	    vmessage("    From contig %s(#%"PRIrec") at %d\n",
		     get_contig_name(find_oligo->io, ABS(obj->c1)),
		     io_clnbr(find_oligo->io, ABS(obj->c1)), obj->pos1);
	    vmessage("    With contig %s(#%"PRIrec") at %d\n",
		     get_contig_name(find_oligo->io, ABS(obj->c2)),
		     io_clnbr(find_oligo->io, ABS(obj->c2)), obj->pos2);
	    vmessage("    Length %d, match %2.2f%%\n\n",
		     obj->length,
		     (float)obj->score / obj->length * 100.0 );
	    end_message(cs->window);
	    break;

	case 1: /* Hide */
	    obj_hide(GetInterp(), cs->window, obj,
		     (mobj_find_oligo *)find_oligo, csplot_hash);
	    break;

	case -2: /* default */
        case 2: /* Invoke join editor */ {
	    tg_rec cnum[2], llino[2];
	    int pos[2];

	    obj->flags |= OBJ_FLAG_VISITED;
	    find_oligo->current = obj - find_oligo->match;
	    Tcl_VarEval(GetInterp(), "CSLastUsed ", CPtr2Tcl(find_oligo), NULL);

	    cnum[0] = ABS(obj->c1);
	    cnum[1] = ABS(obj->c2);

	    /* Complement a contig if needed */
	    if ((obj->c1 > 0) != (obj->c2 > 0)) {
		if (cnum[0] == cnum[1]) {
		    verror(ERR_WARN, "join_editor",
			   "cannot display the same contig in two "
			   "different orientations");
		    break;
		}

		if (find_oligo->io->read_only) {
		    bell();
		    break;
		}

		if (io_clength(find_oligo->io, ABS(obj->c1)) <
		    io_clength(find_oligo->io, ABS(obj->c2))) {
		    if (-1 == complement_contig(find_oligo->io, ABS(obj->c1)))
			if (-1 == complement_contig(find_oligo->io,
						    ABS(obj->c2)))
			    return NULL;
		} else {
		    if (-1 == complement_contig(find_oligo->io, ABS(obj->c2)))
			if (-1 == complement_contig(find_oligo->io,
						    ABS(obj->c1)))
			    return NULL;
		}
	    }

	    /*
	     * NB: obj->pos1 now may not be the same value as when this
	     * function was entered, due to the complementing!
	     */
	    pos[0] = obj->pos1;
	    pos[1] = obj->pos2;

	    llino[0] = io_clnbr(find_oligo->io, cnum[0]);
	    llino[1] = io_clnbr(find_oligo->io, cnum[1]);

	    join_contig(find_oligo->io, cnum, llino, pos);

	    break;
	}

	case 3: /* Invoke contig editors */ {
	    tg_rec cnum, llino;
	    int pos;
	    
	    cnum  = ABS(obj->c1);
	    llino = io_clnbr(find_oligo->io, cnum);
	    pos   = obj->pos1;

	    edit_contig(find_oligo->io, cnum, llino, pos);

	    cnum  = ABS(obj->c2);
	    llino = io_clnbr(find_oligo->io, cnum);
	    pos   = obj->pos2;

	    edit_contig(find_oligo->io, cnum, llino, pos);
	    break;
	}

	case 4: /* Remove */
	    obj_remove(GetInterp(), cs->window, obj,
		       (mobj_find_oligo *)find_oligo, csplot_hash);
	    break;

        }
        break;

    case OBJ_GET_BRIEF:
	sprintf(buf,
		"Oligo: %c#%"PRIrec"@%d with %c#%"PRIrec"@%d, "
		"len %d, match %2.2f%%",
		obj->c1 > 0 ? '+' : '-',
		io_clnbr(find_oligo->io, ABS(obj->c1)), obj->pos1,
		obj->c2 > 0 ? '+' : '-',
		io_clnbr(find_oligo->io, ABS(obj->c2)), obj->pos2,
		obj->length, (float)obj->score / obj->length * 100.0);
	return buf;
    }

    return NULL;
}
Example #8
0
/*
 * functions to act upon matches generated using SEQUENCE
 */
void *find_oligo_obj_func2(int job,
			  void *jdata,
			  obj_match *obj,
			  mobj_find_oligo *find_oligo)
{
    static char buf[80];
    obj_cs *cs;
    int cs_id;

    cs_id = type_to_result(find_oligo->io, REG_TYPE_CONTIGSEL, 0);
    cs = result_data(find_oligo->io, cs_id);

    switch(job) {
    case OBJ_LIST_OPERATIONS:
	return "Information\0Hide\0Invoke contig editor *\0"
	    "SEPARATOR\0Remove\0";

    case OBJ_INVOKE_OPERATION:
	switch(*((int *)jdata)) {
	case 0: /* Information */
	    vfuncgroup(1, "2D plot matches");
	case -1: /* Information from results manager */

	    start_message();
	    vmessage("Sequence search\n");
	    vmessage("    Contig %s(#%"PRIrec") at %d\n",
		     get_contig_name(find_oligo->io, ABS(obj->c1)),
		     io_clnbr(find_oligo->io, ABS(obj->c1)), obj->pos1);
	    vmessage("    Length %d, match %2.2f%%\n\n",
		   obj->length, (float)obj->score / obj->length * 100.0 );
	    end_message(cs->window);
	    break;

	case 1: /* Hide */
	    obj_hide(GetInterp(), cs->window, obj,
		     (mobj_find_oligo *)find_oligo, csplot_hash);
	    break;

	case -2: /* default */
	case 2: /* Invoke contig editor */ {
	    tg_rec cnum, llino;
	    int pos;

	    obj->flags |= OBJ_FLAG_VISITED;
	    find_oligo->current = (int)(obj - find_oligo->match);

	    cnum  = ABS(obj->c1);
	    llino = 0;
	    pos   = obj->pos1;

	    /* FIXME
	    if ((id = editor_available(cnum, 1)) == -1) {
		edit_contig(GetInterp(), find_oligo->io, cnum, llino, pos,
			    consensus_cutoff, quality_cutoff, 0, NULL);
	    }
	    if ((id = editor_available(cnum, 1)) != -1) {
		move_editor(id, llino, pos);
		editor_select_region(id, llino, pos, obj->length);
	    }
	    */

	    edit_contig(find_oligo->io, cnum, llino, pos);

	    break;
	}

	case 3: /* Remove */
	    obj_remove(GetInterp(), cs->window, obj,
		       (mobj_find_oligo *)find_oligo, csplot_hash);
	    break;

        }
        break;

    case OBJ_GET_BRIEF:
	sprintf(buf,
		"Oligo: %c#%"PRIrec"@%d with %c#%"PRIrec"@%d, "
		"len %d, match %2.2f%%",
		obj->c1 > 0 ? '+' : '-',
		io_clnbr(find_oligo->io, ABS(obj->c1)), obj->pos1,
		obj->c2 > 0 ? '+' : '-',
		io_clnbr(find_oligo->io, ABS(obj->c2)), obj->pos2,
		obj->length, (float)obj->score / obj->length * 100.0);
	return buf;
    }

    return NULL;
}