示例#1
0
	void FragmentTree::addRestCleavage(const CleavageCollection& cc, const size_t& cur )
	{
		// Get the number of mono units.
		size_t mono_num = glycan_seq->getBranchByID(0).getUnitNum();
		MassLossWindow mlw = frag_table.getMassLoss();
		for(int nre_clv = NRE_INTACT; nre_clv < NRE_N; nre_clv++)
		{
			// Intact sequence.
			if(nre_clv == NRE_INTACT) {
				// Do nothing.
				//std::cout << "INTACT" << std::endl;
				this->processFragment(cc, mlw);
			} else {
				for(size_t i = 0; i < cur; i++)
				{
					if(nre_clv == X) {
						for(size_t x=0; x<=3; x++)
							for(size_t y = x+2; y <=5; y++)
							{
								if((y - x == 3) || (x == 0 && (y == 4 || y == 5)) || (x == 1 && y == 3))
									continue;
								//std::cout << "X" << i << ":" << x << "-" << y << std::endl;
								//FragmentPtr fg1(new Fragment(*fg));
								//fg1->setFragmentation("X", i, "", x,y);
								CleavageCollection cc1(cc);
								cc1.insert(std::make_pair("X", FragmentPosition(0, i, x, y)));
								this->processFragment(cc1, mlw);
							}
					} else {
						//FragmentPtr fg1(new Fragment(*fg));

						std::string type;
						if(nre_clv == Y) 
							type = "Y";
						else if(nre_clv == Z) 
							type = "Z";
						else 
							throw std::runtime_error("Uncharacterized cleavage type");
						
						//std::cout << type << i << std::endl;
						//fg1->setFragmentation(type, i, "", 0, 0);
						CleavageCollection cc1(cc);
						cc1.insert(std::make_pair(type, FragmentPosition(0, i, 0, 0)));
						this->processFragment(cc1, mlw);
					}
				}
			}
		}
	}
示例#2
0
int matchName(char *c1,const char *c2)
{
	string cc1(c1);
	string cc2(c2);
	if (cc2.find(cc1) != cc2.npos)return 1;
	return 0;
}
            double Point3::getSquaredXYDistanceTo(const Point3 &other) const {
                Point3 cc1(*this);
                cc1.setZ(0);

                Point3 cc2(other);
                cc2.setZ(0);

                return cc1.getSquaredDistanceTo(cc2);
            }
示例#4
0
文件: scc.c 项目: k0gaMSX/scc
int
main(int argc, char *argv[])
{
	int fds[2], st, i;
	char *p;
	pid_t pid;

	atexit(terminate);
	if (p = getenv("ARCH"))
		arch = p;

	for (--argc; *++argv; --argc) {
		if (argv[0][0] != '-' || argv[0][1] == '-')
			break;
		for (p = &argv[0][1]; *p; ++p) {
			switch (*p) {
			case 'm':
				if ((arch = *++argv) == NULL)
					goto usage;
				--argc;
				break;
			default:
			usage:
				usage();
				break;
			}
		}
	}

	if (argc == 0) {
		fputs("scc: fatal error: no input files\n", stderr);
		exit(1);
	}
	if (pipe(fds)) {
		perror("scc: pipe");
		exit(1);
	}

	argcc1[0] = "cc1";
	argcc1[1] = *argv;
	argcc2[0] = "cc2";

	cc1(fds[1]);
	cc2(fds[0]);

	for (i = 0; i < 2; ++i) {
		pid = wait(&st);
		if (pid == pid_cc1)
			pid_cc1 = 0;
		else if (pid == pid_cc2)
			pid_cc2 = 0;
		if (!WIFEXITED(st) || WEXITSTATUS(st) != 0)
			exit(-1);
	}

	return 0;
}
示例#5
0
int main(int argc, char *argv[])
{
	//if (argc != 3) return 1;
	IoChannel src1(argv[1], "r");
	IoChannel dst1(argv[2], "w");
	IoChannel src2(argv[1], "r");
	IoChannel dst2(argv[3], "w");
	CopyChannel cc1(src1, dst1);
	CopyChannel cc2(src2, dst2, 2000);
	GMainLoop *loop = g_main_loop_new(NULL, FALSE);
	g_main_loop_run(loop);
	return 0;
}
    zen_type& operator *= ( const zen_type & other )
    {
        zen_type& zen = static_cast<zen_type&>( *this );
        assert( zen.col() == other.row() );
        static const size_type threshold = 17;
        const size_type max_dims = std::max( std::max( zen.row(), zen.col() ), other.col() );
        const size_type min_dims = std::min( std::min( zen.row(), zen.col() ), other.col() );

        if ( ( max_dims < threshold )  || ( min_dims == 1 ) ) {
            return direct_multiply( other );
        }

        const size_type R = zen.row();
        const size_type C = zen.col();
        const size_type OC = other.col();

        if ( R & 1 )
        {
            if ( R & 2 ) {
                return rr1( other );
            }

            return rr2( other );
        }

        if ( C & 1 )
        {
            if ( C & 2 ) {
                return cc1( other );
            }

            return cc2( other );
        }

        if ( OC & 1 )
        {
            if ( OC & 2 ) {
                return oc1( other );
            }

            return oc2( other );
        }

        return strassen_multiply( other );
    }
示例#7
0
CC_CLZ_Pair CylCutter::singleEdgeDropCanonical(const Point& u1, const Point& u2) const {
    // along the x-axis the cc-point is at x-coord s:
    double s = sqrt( square( radius ) - square( u1.y ) );
    Point cc1(  s, u1.y, 0);
    Point cc2( -s, u1.y, 0);
    cc1.z_projectOntoEdge(u1,u2);
    cc2.z_projectOntoEdge(u1,u2);
    // pick the higher one
    double cc_u;
    double cl_z;
    if (cc1.z > cc2.z) {
        cc_u = cc1.x;
        cl_z = cc1.z;
    } else {
        cc_u = cc2.x;
        cl_z = cc2.z;
    }
    return CC_CLZ_Pair( cc_u, cl_z);
}
int main()
{
	A a;
	B b;
	C c;
	std::shared_ptr<A> ca1(a.clone());
	std::shared_ptr<A> cb1(b.clone());
	std::shared_ptr<A> cc1(c.clone());
	ca1->tell();
	cb1->tell();
	cc1->tell();
	std::shared_ptr<A> ca2(ca1->clone());
	std::shared_ptr<A> cb2(cb1->clone());
	std::shared_ptr<A> cc2(cc1->clone());
	ca2->tell();
	cb2->tell();
	cc2->tell();
	return 0;
}
示例#9
0
/*virtual*/ void RampToGray::_Execute (Arguments& input_args, Arguments& output_args) {

	// validate input arguments
	CheckInputArguments (input_args, GetInputSignature());
	CheckOutputArguments (output_args, GetOutputSignature());
	
	ByteImage in(input_args[0]), out(output_args[0]);
	pI_bool do_create_data(pI_TRUE);
	if (out.HasData()) {
		if ((out.GetChannels() == 1) &&
			(out.GetWidth() == in.GetWidth()) &&
			(out.GetHeight() == in.GetHeight()))
			do_create_data = pI_FALSE;
	}
	if (do_create_data == pI_TRUE) {
		if (out.HasData()) {
			_runtime.GetCRuntime()->FreeArgumentData (
			 _runtime.GetCRuntime(),
			 output_args[0].get());
		}
		out.SetWidth (in.GetWidth());
		out.SetHeight (in.GetHeight());
		out.SetChannels (1);
		try {
			out.CreateData();
		} catch (exception::MemoryException) {
			throw exception::ExecutionException ("Failed to create grayscale image.");
		}
	}

	pI_byte r, g, b;
	pI_float rf, gf, bf;
	pI_size index1, index2;
	// Note: currently, this is done in ByteImage::CreateData()
	// out.SetPitch ((((8 * in.GetWidth()) + 31) / 32) * 4);
	out.SetPath (in.GetPath());
	for (pI_size h = 0; h < in.GetHeight(); ++h) {
		for (pI_size w = 0; w < in.GetWidth(); ++w) {
			r = in.GetData (h, w, 0), g = in.GetData (h, w, 1), b = in.GetData (h, w, 2);
			rf = static_cast<pI_float> (r) / 255.0f;
			gf = static_cast<pI_float> (g) / 255.0f;
			bf = static_cast<pI_float> (b) / 255.0f;
			// in case of gray value, keep it
			if ((r == g) && (r == b)) {
				out.SetData (h, w, 0, r);
				continue;
			}
			GetBestCandidates (rf, gf, bf, index1, index2);
			// check if best candidates are neighbours
			if (std::abs (static_cast<int> (index1) - static_cast<int> (index2)) > 1) {
				// if not, use best candidate
				out.SetData (h, w, 0, static_cast<pI_byte> ((static_cast<float> (index1) / static_cast<float> (_colour_map.size())) * 255.0f));
			} else {
				// otherwise, interpolate
				t_cc cc1(_colour_map[index1 < index2 ? index1 : index2]);
				t_cc cc2(_colour_map[index1 > index2 ? index1 : index2]);
				t_cc diff_cc(Difference (cc1.r, cc2.r), Difference (cc1.g, cc2.g), Difference (cc1.b, cc2.b));
				t_cc diff_p_cc2(Difference (cc2.r, rf), Difference (cc2.g, gf), Difference (cc2.b, bf));
				pI_float norm_diff(0.0f);
				if (diff_cc.r > 0.0)
					norm_diff += diff_p_cc2.r / diff_cc.r;
				if (diff_cc.g > 0.0)
					norm_diff += diff_p_cc2.g / diff_cc.g;
				if (diff_cc.b > 0.0)
					norm_diff += diff_p_cc2.b / diff_cc.b;
				norm_diff /= 3.0f;
				out.SetData (h, w, 0, static_cast<pI_byte> (((static_cast<float> (index1) + norm_diff) / static_cast<float> (_colour_map.size())) * 255.0f));
			}
			
		}
	}
}