DRef DataManager::Import(QDataStream& in) { qint32 type; qint32 version; in >> version; in >> type; if (type == BOI_STD_D(Invalid)) { return DRef(); } // TODO: If the type is a recognized StandardDataType then // the uuid read should be skipped to avoid any extra // unnecessary processing (see QDataStream::skipRawData // and the QString section in "Serializing Qt Data Types"). QString uuid; in >> uuid; QByteArray byteArray; in >> byteArray; if (version == BOI_STD_D_VERSION) { if (type >= StandardDataTypes::NumTypes) { type = ConvertUuid(uuid); } } else { /* * For unknown versions, see if the * uuid is supported by the system. */ type = ConvertUuid(uuid); } if (type != -1) { QBuffer buffer(&byteArray); buffer.open(QIODevice::ReadOnly); QDataStream tempIn(&buffer); Data* pData = GetDataInstance(type); pData->Import(tempIn); buffer.close(); return DRef(pData); } return DRef(); }
void streamContentHandler::generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const { if (!m_stream) return; // Managed data is already encoded if (isEncoded()) { // The data is already encoded but the encoding specified for // the generation is different from the current one. We need // to re-encode data: decode from input buffer to temporary // buffer, and then re-encode to output stream... if (m_encoding != enc) { ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder(); ref <utility::encoder::encoder> theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); m_stream->reset(); // may not work... std::ostringstream oss; utility::outputStreamAdapter tempOut(oss); theDecoder->decode(*m_stream, tempOut); string str = oss.str(); utility::inputStreamStringAdapter tempIn(str); theEncoder->encode(tempIn, os); } // No encoding to perform else { m_stream->reset(); // may not work... utility::bufferedStreamCopy(*m_stream, os); } } // Need to encode data before else { ref <utility::encoder::encoder> theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); m_stream->reset(); // may not work... theEncoder->encode(*m_stream, os); } }
void stringContentHandler::generate(utility::outputStream& os, const vmime::encoding& enc, const size_t maxLineLength) const { // Managed data is already encoded if (isEncoded()) { // The data is already encoded but the encoding specified for // the generation is different from the current one. We need // to re-encode data: decode from input buffer to temporary // buffer, and then re-encode to output stream... if (m_encoding != enc) { shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder(); shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); utility::inputStreamStringProxyAdapter in(m_string); std::ostringstream oss; utility::outputStreamAdapter tempOut(oss); theDecoder->decode(in, tempOut); string str = oss.str(); utility::inputStreamStringAdapter tempIn(str); theEncoder->encode(tempIn, os); } // No encoding to perform else { m_string.extract(os); } } // Need to encode data before else { shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); utility::inputStreamStringProxyAdapter in(m_string); theEncoder->encode(in, os); } }
void IMAPMessagePartContentHandler::generate (utility::outputStream& os, const vmime::encoding& enc, size_t maxLineLength) const { shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock()); shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock()); // Data is already encoded if (isEncoded()) { // The data is already encoded but the encoding specified for // the generation is different from the current one. We need // to re-encode data: decode from input buffer to temporary // buffer, and then re-encode to output stream... if (m_encoding != enc) { // Extract part contents to temporary buffer std::ostringstream oss; utility::outputStreamAdapter tmp(oss); msg->extractPart(part, tmp, NULL); // Decode to another temporary buffer utility::inputStreamStringProxyAdapter in(oss.str()); std::ostringstream oss2; utility::outputStreamAdapter tmp2(oss2); shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder(); theDecoder->decode(in, tmp2); // Reencode to output stream string str = oss2.str(); utility::inputStreamStringAdapter tempIn(str); shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); theEncoder->encode(tempIn, os); } // No encoding to perform else { msg->extractPart(part, os); } } // Need to encode data before else { // Extract part contents to temporary buffer std::ostringstream oss; utility::outputStreamAdapter tmp(oss); msg->extractPart(part, tmp, NULL); // Encode temporary buffer to output stream shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder(); theEncoder->getProperties()["maxlinelength"] = maxLineLength; theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT); utility::inputStreamStringAdapter is(oss.str()); theEncoder->encode(is, os); } }
virtual void THallEffect::filterTo(TSignal & s) { TSignal * in; unsigned int NumberOfPoints; // если это комбинированный сигнал. if( s[0]<-1.0 && s.back() >1.0) { feat(); // его надо усреднить // фильтровать будем усредненный сигнал } // если это обычный сигнал - фильтруем как есть. in=signal; NumberOfPoints=in.size(); // В эти массивы будут достраиваться данные для отрицательных магнитных полей. // Это очень мило, а если это сигнал для отрицательного магнитного поля? // То теоретически достраивается положительная часть. // Надо пофиксить тут комменты на адекватные действительности. TSignal tempIn(2*NumberOfPoints); TSignal tempOut(2*NumberOfPoints); // формируем сигнал для фильтра. // достраивая его в отрицательные магнитные поля. for (unsigned int i = 0; i < NumberOfPoints; i++) { /* Давайте внимательно сюда посмотрим. У эффекта Холла отрицательная симметрия, относительно точки B==0; С чего вообще я взял, что это нулевой элемент? /(О_о)\ Получается для сигнала с положительным магнитным полем - это выполняется. Для сигнала комбинированного, т.е. уже объединенного - это выполняется, потому что фильтруется усредненный сигнал (по сути имеющий только значения положительного магнитного поля. Для отрицательного магнитного поля сие равенство, насколько мне ясно - не выполняется. */ tempIn[i]=-(*inB)[NumberOfPoints-i-1]; tempIn[i+NumberOfPoints]=(*in)[i]; } /* В случае отрицательного магнитного поля надо инвертировать порядок элементов Потому что впереди выстраиваются значения для положительного магнитного поля. */ if(tempIn[0]>1.0) { std::reverse(tempIn.begin(),tempIn.end()); } // фильтруем TrForMassiveFilter(tempIn,tempOut,filterParams.filterLength,filterParams.SamplingFrequecy, filterParams.BandwidthFrequency,filterParams.AttenuationFrequency); // Размер внутри фильтра меняется, в зависимости от длины фильтра. NumberOfPoints=tempOut.size(); s.clear(); for(unsigned int i=fP.filterLength;i<NumberOfPoints;i++) { s.push_back(tempOut[i]); } }
//its okay if the column file does not contain all the names in the fasta file, since some distance may have been above a cutoff, //but no sequences can be in the column file that are not in oldfasta. also, if a distance is above the cutoff given then remove it. //also check to make sure the 2 files have the same alignment length. bool DistanceCommand::sanityCheck() { try{ bool good = true; //make sure the 2 fasta files have the same alignment length ifstream in; m->openInputFile(fastafile, in); int fastaAlignLength = 0; if (in) { Sequence tempIn(in); fastaAlignLength = tempIn.getAligned().length(); } in.close(); ifstream in2; m->openInputFile(oldfastafile, in2); int oldfastaAlignLength = 0; if (in2) { Sequence tempIn2(in2); oldfastaAlignLength = tempIn2.getAligned().length(); } in2.close(); if (fastaAlignLength != oldfastaAlignLength) { m->mothurOut("fasta files do not have the same alignment length."); m->mothurOutEndLine(); return false; } //read fasta file and save names as well as adding them to the alignDB set<string> namesOldFasta; ifstream inFasta; m->openInputFile(oldfastafile, inFasta); while (!inFasta.eof()) { if (m->control_pressed) { inFasta.close(); return good; } Sequence temp(inFasta); if (temp.getName() != "") { namesOldFasta.insert(temp.getName()); //save name alignDB.push_back(temp); //add to DB } m->gobble(inFasta); } inFasta.close(); //read through the column file checking names and removing distances above the cutoff ifstream inDist; m->openInputFile(column, inDist); ofstream outDist; string outputFile = column + ".temp"; m->openOutputFile(outputFile, outDist); string name1, name2; float dist; while (!inDist.eof()) { if (m->control_pressed) { inDist.close(); outDist.close(); m->mothurRemove(outputFile); return good; } inDist >> name1 >> name2 >> dist; m->gobble(inDist); //both names are in fasta file and distance is below cutoff if ((namesOldFasta.count(name1) == 0) || (namesOldFasta.count(name2) == 0)) { good = false; break; } else{ if (dist <= cutoff) { outDist << name1 << '\t' << name2 << '\t' << dist << endl; } } } inDist.close(); outDist.close(); if (good) { m->mothurRemove(column); rename(outputFile.c_str(), column.c_str()); }else{ m->mothurRemove(outputFile); //temp file is bad because file mismatch above } return good; } catch(exception& e) { m->errorOut(e, "DistanceCommand", "sanityCheck"); exit(1); } }