Beispiel #1
0
SEXP makedf_xlpep(struct iobtd *iop){
	SEXP df, df_names, idvec, protidvec, pepflagvec, pepmassvec, pepsitevec;
	yamldom_node_t *xlseq, *tmp, *seq, *prottmp, *peptmp;
	int i, count;
	int id;
	const int ncols=5;

	if(!(xlseq=yamldom_find_map_val(iop->root,"xlink"))){
		goto err;
	}

	count = 0;
	for(seq=YAMLDOM_SEQ_NODES(xlseq);seq;seq=seq->next)
		count += count_seq_elem(yamldom_find_map_val(seq,"peps"));

	hidefromGC(idvec = allocVector(INTSXP,count));
	hidefromGC(protidvec = allocVector(INTSXP,count));
	hidefromGC(pepflagvec = allocVector(INTSXP,count));
	hidefromGC(pepmassvec = allocVector(REALSXP,count));
	hidefromGC(pepsitevec = allocVector(INTSXP,count));

	i=0;
	for(seq=YAMLDOM_SEQ_NODES(xlseq);seq;seq=seq->next){
		if(!(peptmp=yamldom_find_map_val(seq,"peps")))
			goto err;
		peptmp = YAMLDOM_SEQ_NODES(peptmp);

		push_elem(&id,0,seq,"id",strtoint);

		while(peptmp){
			INTEGER(idvec)[i] = id;

			/* prot id/rank (via prot) */
			if(!(prottmp=yamldom_find_map_val(peptmp,"prot")))
				goto err;
			tmp = YAMLDOM_DEREF(prottmp);
			push_elem(INTEGER(protidvec),i,tmp,"id",strtoint);

			push_elem(INTEGER(pepflagvec),i,peptmp,"flags",strtoint);
			push_elem(REAL(pepmassvec),i,peptmp,"mass",strtodouble);
			push_elem(INTEGER(pepsitevec),i,peptmp,"linksite",strtoint);

			i++;
			peptmp = peptmp->next;
		}
	}

	make_list_names(df_names, ncols, "xlid", "protid", "pep.flag", "pep.mass", "pep.xlsite");
	make_dataframe(df, RNULL, df_names, ncols, idvec, protidvec, pepflagvec, pepmassvec, pepsitevec);

	unhideGC();

	return df;

err:
	unhideGC();
	return RNULL;
}
Beispiel #2
0
SEXP makedf_scan(struct iobtd *iop){
	SEXP df, df_names, plidvec, paridvec, sidvec, mzvec, zvec, intvec, rtvec;
	yamldom_node_t *peakseq, *scanseq, *tmp, *seq, *scan;
	int i, count;
	int parid, id;
	const int ncols=7;

	if(!(scanseq=yamldom_find_map_val(iop->root,"scan"))){
		goto err;
	}

	if(!(peakseq=yamldom_find_map_val(iop->root,"peaks"))){
		goto err;
	}

	count=0;
	for(seq=YAMLDOM_SEQ_NODES(peakseq);seq;seq=seq->next){
		if(!(tmp=yamldom_find_map_val(seq,"scans")))
			goto err;
		count += count_seq_elem(tmp);
	}

	hidefromGC(sidvec = allocVector(INTSXP,count));
	hidefromGC(plidvec = allocVector(INTSXP,count));
	hidefromGC(paridvec = allocVector(INTSXP,count));
	hidefromGC(mzvec = allocVector(REALSXP,count));
	hidefromGC(zvec = allocVector(INTSXP,count));
	hidefromGC(rtvec = allocVector(REALSXP,count));
	hidefromGC(intvec = allocVector(REALSXP,count));

	i=0;
	for(seq=YAMLDOM_SEQ_NODES(peakseq);seq;seq=seq->next){
		if(!(tmp=yamldom_find_map_val(seq,"id")))
			goto err;
		id=strtol(((yamldom_scalar_t*)tmp->data)->val,NULL,10);

		if(!(tmp=yamldom_find_map_val(seq,"param")))
			goto err;
		tmp = YAMLDOM_DEREF(tmp);
		if(!(tmp=yamldom_find_map_val(tmp,"id")))
			goto err;
		parid = strtol(((yamldom_scalar_t*)tmp->data)->val,NULL,10);

		if(!(scanseq=yamldom_find_map_val(seq,"scans")))
			goto err;

		for(tmp=YAMLDOM_SEQ_NODES(scanseq);tmp;tmp=tmp->next){
			scan=YAMLDOM_DEREF(tmp);

			INTEGER(plidvec)[i]=id;
			INTEGER(paridvec)[i]=parid;
			push_elem(INTEGER(sidvec),i,scan,"id",strtoint);
			push_elem(INTEGER(zvec),i,scan,"z",strtoint);
			push_elem(REAL(mzvec),i,scan,"mz",strtodouble);
			push_elem(REAL(intvec),i,scan,"preint",strtodouble);
			push_elem(REAL(rtvec),i,scan,"rt",strtodouble);
			if(REAL(rtvec)[i]<0.)
				REAL(rtvec)[i]=0.;

			i++;
		}
	}

	make_list_names(df_names, ncols, "plid", "parid", "scanid", "mz", "z", "rt", "pre.int");
	make_dataframe(df, RNULL, df_names, ncols, plidvec, paridvec, sidvec, mzvec, zvec, rtvec, intvec);

	unhideGC();

	return df;

err:
	unhideGC();
	return RNULL;
}
Beispiel #3
0
SEXP makedf_xlink(struct iobtd *iop){
	SEXP df, df_names, idvec, peakidvec, errvec, covvec, modsv;
	yamldom_node_t *xlseq, *tmp, *seq, *prottmp, *peptmp;
	int i, count, modstrlen;
	const int ncols=5;
	char *mods;

	if(!(xlseq=yamldom_find_map_val(iop->root,"xlink"))){
		goto err;
	}

	count = count_seq_elem(xlseq);

	hidefromGC(idvec = allocVector(INTSXP,count));
	hidefromGC(peakidvec = allocVector(INTSXP,count));
	hidefromGC(errvec = allocVector(REALSXP,count));
	hidefromGC(covvec = allocVector(REALSXP,count));
	hidefromGC(modsv = allocVector(STRSXP,count));

	i=0;
	for(seq=YAMLDOM_SEQ_NODES(xlseq);seq;seq=seq->next){
		if(!(peptmp=yamldom_find_map_val(seq,"peps")))
			goto err;
		peptmp = YAMLDOM_SEQ_NODES(peptmp);

		push_elem(INTEGER(idvec),i,seq,"id",strtoint);
		push_elem(REAL(errvec),i,seq,"error",strtodouble);
		push_elem(REAL(covvec),i,seq,"fragcov",strtodouble);

		/* peaklist id (via prot -> param) */
		if(!(prottmp=yamldom_find_map_val(peptmp,"prot")))
			goto err;
		tmp = YAMLDOM_DEREF(prottmp);
		if(!(tmp=yamldom_find_map_val(tmp,"peaks")))
			goto err;
		tmp = YAMLDOM_DEREF(tmp);
		push_elem(INTEGER(peakidvec),i,tmp,"id",strtoint);
		if(!(tmp=yamldom_find_map_val(tmp,"param")))
			goto err;
		tmp = YAMLDOM_DEREF(tmp);
		modstrlen = getmodstrlen(yamldom_find_map_val(tmp,"vmod"));

		if(!(mods=malloc(modstrlen)))
			goto err;

		modstr(yamldom_find_map_val(seq,"mods"),mods);
		if(mods && *mods)
			SET_STRING_ELT(modsv, i, mkChar(mods));
		else
			SET_STRING_ELT(modsv, i, mkChar(""));

		free(mods);

		i++;
	}

	make_list_names(df_names, ncols, "xlid", "peakid", "error", "frag.cov", "mods");
	make_dataframe(df, RNULL, df_names, ncols, idvec, peakidvec, errvec, covvec, modsv);

	unhideGC();

	return df;

err:
	unhideGC();
	return RNULL;
}
Beispiel #4
0
int run_shell() {
	Value tmp_value;
	int ascii_code = -1;
	int cmd_code = -1;

	wprintf(L"");

	for (;;) {
		tmp_value = get_char();
		ascii_code = tmp_value.integer;

		// EXPECTATIONS
		cmd_code = analyse_expectations(ascii_code);

		//wprintf(L"%d %d %lc\n",ascii_code, cmd_code, tmp_value.character);

		switch(cmd_code) {
			case EOT_CMD:
				quit_shell();
				break;
			case DEL_L:
				delete_from_buffer(false);
				break;
			case DEL_R:
				delete_from_buffer(true);
				break;
			case UP_A_K:
				wprintf(L"UP");
				break;
			case DOWN_A_K:
				wprintf(L"DOWN");
				break;
			case RIGHT_A_K:
				move_cusor(CURSOR_DIR_RIGHT);
				break;
			case LEFT_A_K:
				move_cusor(CURSOR_DIR_LEFT);
				break;
			case BEGIN:
				move_cusor(CURSOR_DIR_BEGIN);
				break;
			case END:
				move_cusor(CURSOR_DIR_END);
				break;
			case ENTER_CMD:
				if(handle_cmd() == RET_ERROR) {
					print_error("Error while executing command!");
				}
				break;
			case NO_CMD:
				push_elem(buffer, tmp_value);
				print_buffer(true);
				break;
			default:
				//printf("%d => %c\n", ascii_code, tmp_value.character);
				break;
		}
	}

	return RET_OK;
}