示例#1
0
文件: main.cpp 项目: imgag/ngs-bits
	virtual void main()
	{
		//init
		StatisticsReads stats;
		FastqEntry entry;
		QStringList infiles;
		QStringList in1 = getInfileList("in1");
		QStringList in2 = getInfileList("in2");
		if (in2.count()!=0 && in1.count()!=in2.count())
		{
			THROW(CommandLineParsingException, "Input file lists 'in1' and 'in2' differ in counts!");
		}

		//process
		for (int i=0; i<in1.count(); ++i)
		{
			//forward
			FastqFileStream stream(in1[i]);
			while(!stream.atEnd())
			{
				stream.readEntry(entry);
				stats.update(entry, StatisticsReads::FORWARD);
			}
			infiles << in1[i];

			//reverse (optional)
			if (i<in2.count())
			{
				FastqFileStream stream2(in2[i]);
				while(!stream2.atEnd())
				{
					 stream2.readEntry(entry);
					 stats.update(entry, StatisticsReads::REVERSE);
				}

				//check read counts matches
				if (stream.index()!=stream2.index())
				{
					THROW(ArgumentException, "Differing number of reads in file '" + in1[i] + "' and '" + in2[i] + "'!");
				}

				infiles << in2[i];
			}
		}

		//store output
		QCCollection metrics = stats.getResult();
		if (getFlag("txt"))
		{
			QStringList output;
			metrics.appendToStringList(output);
			Helper::storeTextFile(Helper::openFileForWriting(getOutfile("out"), true), output);
		}
		else
		{
			metrics.storeToQCML(getOutfile("out"), infiles, "");
		}
	}
示例#2
0
	virtual void main()
	{
		//init
		StatisticsReads stats;
		FastqEntry entry;
		QStringList infiles;

		//process forward read file
		QString in1 = getInfile("in1");
		FastqFileStream stream(in1);
		while(!stream.atEnd())
		{
			stream.readEntry(entry);
			stats.update(entry, StatisticsReads::FORWARD);
		}
		infiles << in1;

		//process reverse read file
		QString in2 = getInfile("in2");
		if (in2!="")
		{
			FastqFileStream stream2(in2);
			while(!stream2.atEnd())
			{
				 stream2.readEntry(entry);
				 stats.update(entry, StatisticsReads::REVERSE);
			}

			//check read counts matches
			if (stream.index()!=stream2.index())
			{
				THROW(ArgumentException, "Differing number of reads in file '" + in1 + "' and '" + in2 + "'!");
			}

			infiles << in2;
		}

		//store output
		QCCollection metrics = stats.getResult();
		if (getFlag("txt"))
		{
			QStringList output;
			metrics.appendToStringList(output);
			Helper::storeTextFile(Helper::openFileForWriting(getOutfile("out"), true), output);
		}
		else
		{
			metrics.storeToQCML(getOutfile("out"), infiles, "");
		}
	}
示例#3
0
void QCCollection::insert(const QCCollection& collection)
{
	for (int i=0; i<collection.count(); ++i)
	{
		insert(collection[i]);
	}
}
示例#4
0
QCCollection NGSD::getQCData(const QString& filename)
{
	QString ps_id = processedSampleId(filename, false);

	//get QC data
	SqlQuery q = getQuery();
	q.exec("SELECT n.name, nm.value, n.description, n.qcml_id FROM processed_sample_qc as nm, qc_terms as n WHERE nm.processed_sample_id='" + ps_id + "' AND nm.qc_terms_id=n.id");
	QCCollection output;
	while(q.next())
	{
		output.insert(QCValue(q.value(0).toString(), q.value(1).toString(), q.value(2).toString(), q.value(3).toString()));
	}

	//get KASP data
	SqlQuery q2 = getQuery();
	q2.exec("SELECT random_error_prob FROM kasp_status WHERE processed_sample_id='" + ps_id + "'");
	QString value = "n/a";
	if (q2.size()>0)
	{
		q2.next();
		float numeric_value = 100.0 * q2.value(0).toFloat();
		if (numeric_value>100.0) //special case: random_error_prob>100%
		{
			value = "<font color=orange>KASP not performed (see NGSD)</font>";
		}
		else if (numeric_value>1.0) //random_error_prob>1% => warn
		{
			value = "<font color=red>"+QString::number(numeric_value)+"%</font>";
		}
		else
		{
			value = QString::number(numeric_value)+"%";
		}
	}
	output.insert(QCValue("kasp", value));

	return output;
}
示例#5
0
文件: main.cpp 项目: imgag/ngs-bits
    virtual void main()
    {
        //init
        QString roi_file = getInfile("roi");
        bool wgs = getFlag("wgs");
        QString in = getInfile("in");
        int min_maqp = getInt("min_mapq");

        //check that either ROI or WGS is given
        if (roi_file=="" && !wgs)
        {
            THROW(CommandLineParsingException, "You have to provide the parameter 'roi' or 'wgs'!");
        }

        QStringList parameters;
        QCCollection metrics;
        if (wgs)
        {
            metrics = Statistics::mapping(in, min_maqp);

            //parameters
            parameters << "-wgs";
        }
        else
        {
            //load ROI
            BedFile roi;
            roi.load(roi_file);
            roi.merge();

            //calculate metrics
            metrics = Statistics::mapping(roi, in, min_maqp);

            //parameters
            parameters << "-roi" << QFileInfo(roi_file).fileName();
        }

        //special QC for 3 exons
        QMap<QString, int> precision_overwrite;
        precision_overwrite.insert("error estimation N percentage", 4);
        precision_overwrite.insert("error estimation SNV percentage", 4);
        precision_overwrite.insert("error estimation indel percentage", 4);
        QCCollection metrics_3exons;
        if (getFlag("3exons"))
        {
            metrics_3exons = Statistics::mapping3Exons(in);

            //parameters
            parameters << "-3exons";
        }

        //store output
        QString out = getOutfile("out");
        if (getFlag("txt"))
        {
            QStringList output;
            metrics.appendToStringList(output);
            output << "";
            metrics_3exons.appendToStringList(output, precision_overwrite);
            Helper::storeTextFile(Helper::openFileForWriting(out, true), output);
        }
        else
        {
            metrics.insert(metrics_3exons);
            metrics.storeToQCML(out, QStringList() << in, parameters.join(" "), precision_overwrite);
        }
    }