Пример #1
0
int main(int argc, char const ** argv)
{
    if (argc != 2)
    {
        std::cerr << "USAGE: " << argv[0] << " IN.bam\n";
        return 1;
    }

    // Open BGZF Stream for reading.
    seqan::Stream<seqan::Bgzf> inStream;
    if (!open(inStream, argv[1], "r"))
    {
        std::cerr << "ERROR: Could not open " << argv[1] << " for reading.\n";
        return 1;
    }

    // Setup name store, cache, and BAM I/O context.
    typedef seqan::StringSet<seqan::CharString> TNameStore;
    typedef seqan::NameStoreCache<TNameStore>   TNameStoreCache;
    typedef seqan::BamIOContext<TNameStore>     TBamIOContext;
    TNameStore      nameStore;
    TNameStoreCache nameStoreCache(nameStore);
    TBamIOContext   context(nameStore, nameStoreCache);

    // Read header.
    seqan::BamHeader header;
    if (readRecord(header, context, inStream, seqan::Bam()) != 0)
    {
        std::cerr << "ERROR: Could not read header from BAM file " << argv[1] << "\n";
        return 1;
    }

    // Write out header again.
    if (write2(std::cout, header, context, seqan::Sam()) != 0)
    {
        std::cerr << "ERROR: Could not write header to stdout.\n";
        return 1;
    }

    // Copy over the alignment records.
    seqan::BamAlignmentRecord record;
    while (!atEnd(inStream))
    {
        if (readRecord(record, context, inStream, seqan::Bam()) != 0)
        {
            std::cerr << "ERROR: Could not read record from BAM File " << argv[1] << "\n";
            return 1;
        }

        if (write2(std::cout, record, context, seqan::Sam()) != 0)
        {
            std::cerr << "ERROR: Could not write record to stdout.\n";
            return 1;
        }
    }

    return 0;
}
Пример #2
0
DWORD 
eventNotify_t::dumpNewRecords(void)
{
	EVENTLOGRECORD*				rec		= nullptr;
	BYTE*						ptr		= nullptr;
	eventLogEntry_t*			e		= nullptr;
	wchar_t*					wnam	= nullptr;
	QString						nam		= "";
    DWORD						status	= ERROR_SUCCESS;

	status = readRecord(ptr, 0, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ);
    
	if (ERROR_SUCCESS != status && ERROR_HANDLE_EOF != status) {
		if (nullptr != ptr)
			delete ptr;

		return status;
    }

	

    while (ERROR_HANDLE_EOF != status) {
		rec		= reinterpret_cast< EVENTLOGRECORD* >(ptr);
		wnam	= reinterpret_cast< wchar_t* >(reinterpret_cast< unsigned char* >(ptr + sizeof(EVENTLOGRECORD)));

		if (nullptr == wnam) {
			delete ptr;
			ptr = nullptr;
			return ERROR_INVALID_PARAMETER; // XXX JF FIXME
		}

		nam = QString::fromWCharArray(wnam);

		if (! nam.compare("WINHTTPD-Controller", Qt::CaseInsensitive) || ! nam.compare("WINHTTPD-Worker", Qt::CaseInsensitive)) {
			e = new eventLogEntry_t(*rec); //std::make_shared< eventLogEntry_t >(*rec);
			emit addRecord(e);
			//e = nullptr;
		}

		delete ptr;
		ptr = nullptr;

		status = readRecord(ptr, 0, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ);

        if (ERROR_SUCCESS != status && ERROR_HANDLE_EOF != status) {
            if (nullptr != ptr)
				delete ptr;

			return status;
        }
    }

    if (ERROR_HANDLE_EOF == status) 
        status = ERROR_SUCCESS;

    return status;
}
/**
 * Deletes a record from table
 *
 * rel = table handle
 * id = id of the record to be deleted
 *
 */
RC deleteRecord(RM_TableData *rel, RID id) {

	//Sanity Checks
	if (rel == NULL) {
		THROW(RC_INVALID_HANDLE, "Table handle is invalid");
	}

	Record *record;
	//Read the record to be deleted
	createRecord(&record, rel->schema);
	RC rc = readRecord(rel, id, &record);
	if (rc != RC_OK) {
		THROW(RC_REC_MGR_DELETE_REC_FAILED, "Delete record failed");
	}

	//Set tomstone bit
	record->nullMap |= 1 << 15;

	//Write updated record
	rc = writeRecord(rel, record);
	freeRecord(record);

	if (rc == RC_OK)
		((RM_TableMgmtData *) rel->mgmtData)->tupleCount--;
	else {
		THROW(RC_REC_MGR_DELETE_REC_FAILED, "Delete record failed");
	}

	return rc;
}
Пример #4
0
bool Parser::loadFromStream( QDataStream &stream ) 
{
    stream.setByteOrder( QDataStream::LittleEndian );

    Header *header = new Header( stream );
    if ( ! header->isValid() ) {
        kWarning() << "Failed to parse header, perhaps not an EMF file";
        delete header;
        return false;
    }

    mOutput->init( header );

#if DEBUG_EMFPARSER
    kDebug(31000) << "========================================================== Starting EMF";
#endif

    int numRecords = header->recordCount();
    for ( int i = 1; i < numRecords; ++i ) {
        // kDebug(33100) << "Record" << i << "of" << numRecords;
        if ( ! readRecord( stream ) ) {
            break;
        }
    }

    mOutput->cleanup( header );

    delete header;

    return true;
}
Пример #5
0
int main(int argc, char const ** argv)
{
    if (argc != 2)
        return 1;  // Invalid number of arguments.

    // Open file and create RecordReader.
    std::fstream in(argv[1], std::ios::binary | std::ios::in);
    seqan::RecordReader<std::fstream, seqan::SinglePass<> > reader(in);

    // Create the AutoSeqStreamFormat object and guess the file format.
    seqan::AutoSeqStreamFormat formatTag;
    if (!guessStreamFormat(reader, formatTag))
        return 1;  // Could not detect file format.

    // Read file record-wise.
    seqan::CharString id;
    seqan::String<seqan::Dna5Q> seq;
    while (!atEnd(reader))
    {
        if (readRecord(id, seq, reader, formatTag) != 0)
            return 1;  // Could not record from file.

        std::cout << id << "\t" << seq << "\n";
    }
    
    return 0;
}
Пример #6
0
DWORD 
eventNotify_t::seekToLastRecord(void)
{
	DWORD sta = ERROR_SUCCESS;
	DWORD num = 0;
	PBYTE rec = nullptr;  

	sta = getLastRecordNumber(num);

	if (ERROR_SUCCESS != sta) {
		emit errorMessage("Error in eventNotify::seekToLastRecord()","Error while attempting to get the last record number", true);
		return sta;
	}

	sta = readRecord(rec, num, EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ);

	if (ERROR_SUCCESS != sta && ERROR_HANDLE_EOF != sta) {
		emit errorMessage("Error in eventNotify_t::seekToLastRecord()","Error while attempting to read event log record", true);
		return sta;
	}

	if (nullptr != rec)
		::free(rec);

	if (ERROR_HANDLE_EOF == sta)
		sta = ERROR_SUCCESS;

	return sta;
}
Пример #7
0
	int SimplePlanReader::Impose()
	{
		std::ifstream in ( planPath.c_str(), std::ifstream::in );
		if ( !in.good() )
			throw std::runtime_error ( "Failed to open plan file" );
		char cbuffer[OSPI_MAX_RECORD_SIZE];
		int blen (0);
		do
		{
			in.getline ( cbuffer, OSPI_MAX_RECORD_SIZE );
			blen = in.gcount() ;
			std::string buffer ( cbuffer, blen );
			readRecord(buffer);
		}
		while(!in.eof());

		// Results
		std::cerr<<"Documents: "<<tdocuments.size()<<std::endl;
		std::cerr<<"Pages:" <<spages.size()<<std::endl;
		BOOST_FOREACH(SourcePagePtr spp, spages)
		{
			spp->commit();
		}
		BOOST_FOREACH(DocInfoKey k, tdocuments)
		{
			k.second->SetWriteMode(PoDoFo::ePdfWriteMode_Clean);
			k.second->Write(k.first.c_str());
		}
Пример #8
0
int main(void)
{
    ifstream gradeDataFile;
    char fileName[FILENAME_SIZE];
    int recordNumber;
    int numGrades;
    char studentName[25];
    int studentGrades[100];
    
    recordNumber = 1;
    
    system("cls");

    getFileName( fileName );
    openDataFile( gradeDataFile, fileName );
    setGradeCount( gradeDataFile, numGrades );

    while( gradeDataFile.peek() != EOF )
    {
        cout << setw(3) << recordNumber << "  ";
        readRecord( gradeDataFile, studentName, studentGrades, numGrades );
        cout << studentName << "  ";
        cout << setw(6) << fixed << setprecision(2) << showpoint << avgForRecord( studentGrades, numGrades ) << "  ";
        cout << setw(6) << fixed << setprecision(2) << showpoint << devForRecord( studentGrades, numGrades ) << endl;
        recordNumber++;
    }
    
    gradeDataFile.close();
}
Пример #9
0
        /**
         *  Finds a particular fasta header in a fasta file and returns the associated sequence
         **/
        static int getEntryFromFasta(const path& fasta_path, const string& header, string& sequence)
        {
            // Setup stream to sequence file and check all is well
            std::ifstream inputStream (fasta_path.c_str());

            if (!inputStream.is_open())
            {
                std::cerr << "ERROR: Could not open the sequence file: " << fasta_path << endl;
                return 0;
            }

            string id;
            string seq;

            // Read a record
            while(inputStream.good() && readRecord(inputStream, id, seq) == 0)
            {
                stringstream ssHeader;
                ssHeader << id;

                if (header.compare(ssHeader.str()) == 0)
                {
                    inputStream.close();
                    sequence = seq;

                    return 0;
                }
                seq.clear();
            }

            inputStream.close();
            return -1;
        }
Пример #10
0
        /**
         *  Finds the nth entry from the fasta file and returns the associated sequence
         **/
        static int getEntryFromFasta(const path& fasta_path, uint32_t n, string& header, string& sequence)
        {
            // Setup stream to sequence file and check all is well
            std::ifstream inputStream (fasta_path.c_str());

            if (!inputStream.is_open())
            {
                std::cerr << "ERROR: Could not open the sequence file: " << fasta_path << endl;
                return 0;
            }


            std::string id;
            std::string seq;
            uint32_t i = 1;

            // Read a record
            while(inputStream.good() && readRecord(inputStream, id, seq) == 0)
            {
                if (i == n)
                {
                    inputStream.close();

                    header.swap(id);
                    sequence = seq;
                    return 0;
                }

                seq.clear();
                i++;
            }

            inputStream.close();
            return -1;
        }
int main(int argc, char const ** argv)
{
	//parse our options
	ModifyStringOptions options;
	seqan::ArgumentParser::ParseResult res = parseCommandLine(options, argc, argv);

	// If parsing was not successful then exit with code 1 if there were errors.
	// Otherwise, exit with code 0 (e.g. help was printed).
	if (res != seqan::ArgumentParser::PARSE_OK)
		return res == seqan::ArgumentParser::PARSE_ERROR;	


	SeqFileIn seqFileIn;
	if (!open(seqFileIn, toCString(options.inputFileName)))
	{
		std::cerr << "ERROR: Could not open the file.\n";
		return 1;
	}

	CharString id;
	Dna5String seq;
	CharString qual;

	SeqFileOut seqFileOut;
        if (!open(seqFileOut, toCString(options.outputFileName)))
        {
                std::cerr << "ERROR: Could not open the file.\n";
                return 1;
        }

	while(!atEnd(seqFileIn))
	{
        	try
        	{
        	        readRecord(id, seq, qual, seqFileIn);
        	}
        	catch (Exception const & e)
        	{
        	        std::cout << "ERROR: " << e.what() << std::endl;
        	        return 1;
        	}

               	if(length(seq) >= options.length)
               	{
                       	String<Dna> dnaSeq;
               	        resize(dnaSeq, options.length, Exact());
               	        assign(dnaSeq, seq, Limit());

               	        CharString dnaQual;
               	        resize(dnaQual, options.length, Exact());
               	        assign(dnaQual, qual, Limit());

			writeRecord(seqFileOut, id, dnaSeq, dnaQual);			
		}
	}
	
	return 0;
}
Пример #12
0
void EventRecorder::deinit() {
	debug(3, "EventRecorder: deinit");

	g_system->getEventManager()->getEventDispatcher()->unregisterSource(this);
	g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this);

	g_system->lockMutex(_timeMutex);
	g_system->lockMutex(_recorderMutex);
	_recordMode = kPassthrough;
	g_system->unlockMutex(_timeMutex);
	g_system->unlockMutex(_recorderMutex);

	delete _playbackFile;
	delete _playbackTimeFile;

	if (_recordFile != NULL) {
		_recordFile->finalize();
		delete _recordFile;
		_recordTimeFile->finalize();
		delete _recordTimeFile;

		_playbackFile = g_system->getSavefileManager()->openForLoading(_recordTempFileName);

		assert(_playbackFile);

		_recordFile = g_system->getSavefileManager()->openForSaving(_recordFileName);
		_recordFile->writeUint32LE(RECORD_SIGNATURE);
		_recordFile->writeUint32LE(RECORD_VERSION);

		// conf vars
		_recordFile->writeByte(_recordSubtitles ? 1 : 0);

		_recordFile->writeUint32LE(_recordCount);
		_recordFile->writeUint32LE(_recordTimeCount);

		_recordFile->writeUint32LE(_randomSourceRecords.size());
		for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
			_recordFile->writeUint32LE(_randomSourceRecords[i].name.size());
			_recordFile->writeString(_randomSourceRecords[i].name);
			_recordFile->writeUint32LE(_randomSourceRecords[i].seed);
		}

		for (uint i = 0; i < _recordCount; ++i) {
			uint32 tempDiff;
			Event tempEvent;
			uint32 millis;
			readRecord(_playbackFile, tempDiff, tempEvent, millis);
			writeRecord(_recordFile, tempDiff, tempEvent, millis);
		}

		_recordFile->finalize();
		delete _recordFile;
		delete _playbackFile;

		//TODO: remove recordTempFileName'ed file
	}
}
Пример #13
0
void VcfMaterializer::init()
{
    if (!empty(vcfFileName))
    {
        // Open VCF stream.
        if (!open(vcfFileIn, toCString(vcfFileName)))
            throw MasonIOException("Could not open VCF stream.");

        // Read header.
        readHeader(vcfHeader, vcfFileIn);

        // Read first VCF record.
        if (!atEnd(vcfFileIn))
            readRecord(vcfRecord, vcfFileIn);

        // Get number of haplotypes in VCF file.
        SEQAN_ASSERT_NOT(empty(vcfRecord.genotypeInfos));
        seqan::StringSet<seqan::CharString> xs;
        seqan::DirectionIterator<seqan::CharString const, seqan::Input>::Type inputIter =
                directionIterator(vcfRecord.genotypeInfos[0], seqan::Input());
        numHaplotypes = 1;
        for (; !atEnd(inputIter); ++inputIter)
            numHaplotypes += (*inputIter == '|' || *inputIter == '/');
    }
    else
    {
        numHaplotypes = 1;
    }

    // Open input FASTA file and FAI.
    if (!open(faiIndex, toCString(fastaFileName)))
    {
        if (!build(faiIndex, toCString(fastaFileName)))
            throw MasonIOException("Could not build FAI index.");

        seqan::CharString faiPath = fastaFileName;
        append(faiPath, ".fai");
        if (!save(faiIndex, toCString(faiPath)))
            throw MasonIOException("Could not write FAI index.");
    }

    // Open methylation FASTA FAI file if given.
    if (!empty(methFastaFileName))
    {
        if (!open(methFaiIndex, toCString(methFastaFileName)))
        {
            if (!build(methFaiIndex, toCString(methFastaFileName)))
                throw MasonIOException("Could not build methylation levels FAI index.");

            seqan::CharString faiPath = methFastaFileName;
            append(faiPath, ".fai");
            if (!save(methFaiIndex, toCString(faiPath)))
                throw MasonIOException("Could not write methylation levels FAI index.");
        }
    }
}
Пример #14
0
int 
main(int nargs, char *argv[])
{

	char line[MAX_NUM_CHARS];
	while(fgets(line, MAX_NUM_CHARS, stdin)) {
	readRecord(line, FIELD_NUM);
    }
    return(0);
}
Пример #15
0
void polyLine::getPoint(FILE* file) {
	int shapeType;
	readRecord(&shapeType, file);
	PolyLineType *ret = new PolyLineType;
	readRecord((char*)ret, file, 40);

	int a;
	for (int i = 0; i < ret->numParts; i++) {
		readRecord(&a, file);
		ret->Parts.push_back(a);
	}

	double cord[2];
	for (int i = 0; i < ret->numPoints; i++) {
		readRecord(cord, file, 2);
		ret->Points.push_back(PointType(cord[0], cord[1]));
	}

	objSet->push_back(ret);
}
/**
 * Reads a record from table
 *
 * rel = table handle
 * id = id of the record to be read
 * record = updated record to be written
 *
 */
RC getRecord(RM_TableData *rel, RID id, Record *record) {

	//Sanity Checks
	if (rel == NULL) {
		THROW(RC_INVALID_HANDLE, "Table handle is invalid");
	}

	if (record == NULL) {
		THROW(RC_INVALID_HANDLE, "Record handle is invalid");
	}

	return readRecord(rel, id, &record);
}
Пример #17
0
int main(int argc, char const ** argv)
{
    if (argc != 3)
    {
        std::cerr << "USAGE: " << argv[0] << " IN.bam OUT.bam\n";
        return 1;
    }

    // Open BGZF Stream for reading.
    seqan::Stream<seqan::Bgzf> inStream;
    if (!open(inStream, argv[1], "r"))
    {
        std::cerr << "ERROR: Could not open " << argv[1] << " for reading.\n";
        return 1;
    }

    // Open BGZF Stream for writing.
    seqan::Stream<seqan::Bgzf> outStream;
    if (!open(outStream, argv[2], "w"))
    {
        std::cerr << "ERROR: Could not open " << argv[2] << " for writing.\n";
        return 1;
    }

    // Setup name store, cache, and BAM I/O context.
    typedef seqan::StringSet<seqan::CharString> TNameStore;
    typedef seqan::NameStoreCache<TNameStore>   TNameStoreCache;
    typedef seqan::BamIOContext<TNameStore>     TBamIOContext;
    TNameStore      nameStore;
    TNameStoreCache nameStoreCache(nameStore);
    TBamIOContext   context(nameStore, nameStoreCache);

    // Read header.
    seqan::BamHeader header;
    if (readRecord(header, context, inStream, seqan::Bam()) != 0)
    {
        std::cerr << "ERROR: Could not read header from BAM file " << argv[1] << "\n";
        return 1;
    }

    // Write out header again.
    if (write2(outStream, header, context, seqan::Bam()) != 0)
    {
        std::cerr << "ERROR: Could not write header to BAM file " << argv[2] << "\n";
        return 1;
    }

    return 0;
}
Пример #18
0
selectByName(char* fname, char* name)
{


    int page_hdr = 4;
    int i;
    int fd,pagenum;
    int *buf;
    int error;



    //printf("opening %s\n",fname);
	if ((fd=PF_OpenFile(fname))<0){
		PF_PrintError("open file");
		exit(1);
	}

	pagenum = -1;
	while ((error=PF_GetNextPage(fd,&pagenum,&buf))== PFE_OK){

        struct Record r;
        int n_tuppp = buf[0];
        int i = 0;
        for(; i < n_tuppp; ++i)
        {
            readRecord(&r, page_hdr + i * sizeof(r), sizeof(r), buf);
            if(strcmp(r.name, name)){
                // Do something
                PF_PrintError(":)");
            }
        }
		if ((error=PF_UnfixPage(fd,pagenum,FALSE))!= PFE_OK){
			PF_PrintError("unfix");
			exit(1);
		}
	}



	if ((error=PF_CloseFile(fd))!= PFE_OK){
		PF_PrintError("close file");
		exit(1);
	}

}
Пример #19
0
int main()
{
    // Open input stream
    seqan::GffStream gffIn("example.gff");
    if (!isGood(gffIn))
    {
        std::cerr << "ERROR: Could not open example.gff\n";
        return 1;
    }

    // Array of counters and sequence names.
    seqan::String<unsigned> counters;
    seqan::StringSet<seqan::CharString> seqNames;

    // Read the file record by record.
    seqan::GffRecord record;
    while (!atEnd(gffIn))
    {
        if (readRecord(record, gffIn) != 0)
        {
            std::cerr << "ERROR: Problem reading from example.gff\n";
            return 1;
        }

        // Resize counters and write seqNames if necessary.
        if ((int)length(counters) <= record.rID)
        {
            resize(counters, record.rID + 1, 0);
            resize(seqNames, record.rID + 1);
        }
        if (counters[record.rID] == 0)
            seqNames[record.rID] = record.ref;

        // Register record with counters.
        counters[record.rID] += 1;
    }

    // Print result.
    std::cout << "RECORDS ON CONTIGS\n";
    for (unsigned i = 0; i < length(seqNames); ++i)
        if (counters[i] > 0u)
            std::cout << seqNames[i] << '\t' << counters[i] << '\n';
    
    return 0;
}
Пример #20
0
// - delete record
bferr TBinFileBase::deleteRecord(uInt32 aIndex)
{
  if (!platformFileIsOpen()) return BFE_NOTOPEN;
  if (aIndex>=fBinFileHeader.numrecords) return BFE_BADINDEX;
  if (aIndex<fBinFileHeader.numrecords-1) {
    // we need to move last record
    void *recP = malloc(fBinFileHeader.recordsize);
    if (!recP) return BFE_IOERR; // no memory
    // read last record
    readRecord(fBinFileHeader.numrecords-1,recP);
    // write it to new position
    updateRecord(aIndex,recP);
    free(recP);
  }
  fBinFileHeader.numrecords--;
  fHeaderDirty=true;
  return BFE_OK;
} // TBinFileBase::deleteRecord
bool PluckerBookReader::readDocument() {
	myStream = ZLFile(myFilePath).inputStream();
	if (myStream.isNull() || !myStream->open()) {
		return false;
	}

	PdbHeader header;
	if (!header.read(myStream)) {
		myStream->close();
		return false;
	}

	setMainTextModel();
	myFont = FT_REGULAR;

	for (std::vector<unsigned long>::const_iterator it = header.Offsets.begin(); it != header.Offsets.end(); ++it) {
		size_t currentOffset = myStream->offset();
		if (currentOffset > *it) {
			break;
		}
		myStream->seek(*it - currentOffset, false);
		if (myStream->offset() != *it) {
			break;
		}
		size_t recordSize = ((it != header.Offsets.end() - 1) ? *(it + 1) : myStream->sizeOfOpened()) - *it;
		readRecord(recordSize);
	}
	myStream->close();

	for (std::set<std::pair<int,int> >::const_iterator it = myReferencedParagraphs.begin(); it != myReferencedParagraphs.end(); ++it) {
		std::map<int,std::vector<int> >::const_iterator jt = myParagraphMap.find(it->first);
		if (jt != myParagraphMap.end()) {
			for (unsigned int k = it->second; k < jt->second.size(); ++k) {
				if (jt->second[k] != -1) {
					addHyperlinkLabel(fromNumber(it->first) + '#' + fromNumber(it->second), jt->second[k]);
					break;
				}
			}
		}
	}
	myReferencedParagraphs.clear();
	myParagraphMap.clear();
	return true;
}
Пример #22
0
int VcfMaterializer::_loadVariantsForContig(Variants & variants, int rID)
{
    variants.clear();

    // Compute number of haplotypes.
    SEQAN_ASSERT_NOT(empty(vcfRecord.genotypeInfos));
    seqan::StringSet<seqan::CharString> xs;
    seqan::DirectionIterator<seqan::CharString const, seqan::Input>::Type inputIter =
            directionIterator(vcfRecord.genotypeInfos[0], seqan::Input());
    numHaplotypes = 1;
    for (; !atEnd(inputIter); ++inputIter)
        numHaplotypes += (*inputIter == '|' || *inputIter == '/');

    std::vector<seqan::VcfRecord> chunk;
    while (vcfRecord.rID != -1 && vcfRecord.rID <= rID)
    {
        // Translocations are the only SVs that are stored as breakends (BND).  We collect the BNDs in chunks of 6
        // which then represent a translocation.  Requiring that the BNDs are stored in adjacent chunks of 6 records
        // is a strong limitation but supporting more generic variations would be a bit too much here.
        if (contains(vcfRecord.info, "SVTYPE=BND"))
        {
            chunk.push_back(vcfRecord);
            if (chunk.size() == 6u)
            {
                _appendToVariantsBnd(variants, chunk);
                chunk.clear();
            }
        }
        else
        {
            SEQAN_CHECK(chunk.size() == 0u, "Found chunk of != 6 BND records!");
            _appendToVariants(variants, vcfRecord);
        }

        if (atEnd(vcfFileIn))
        {
            vcfRecord.rID = -1;
            continue;
        }
        readRecord(vcfRecord, vcfFileIn);
    }

    return 0;
}
Пример #23
0
bool EventRecorder::pollEvent(Event &ev) {
	uint32 millis;

	if (_recordMode != kRecorderPlayback)
		return false;

	StackLock lock(_recorderMutex);
	++_eventCount;

	if (!_hasPlaybackEvent) {
		if (_recordCount > _playbackCount) {
			readRecord(_playbackFile, const_cast<uint32&>(_playbackDiff), _playbackEvent, millis);
			_playbackCount++;
			_hasPlaybackEvent = true;
		}
	}

	if (_hasPlaybackEvent) {
		if (_playbackDiff <= (_eventCount - _lastEventCount)) {
			switch (_playbackEvent.type) {
			case EVENT_MOUSEMOVE:
			case EVENT_LBUTTONDOWN:
			case EVENT_LBUTTONUP:
			case EVENT_RBUTTONDOWN:
			case EVENT_RBUTTONUP:
			case EVENT_WHEELUP:
			case EVENT_WHEELDOWN:
				g_system->warpMouse(_playbackEvent.mouse.x, _playbackEvent.mouse.y);
				break;
			default:
				break;
			}
			ev = _playbackEvent;
			_hasPlaybackEvent = false;
			_lastEventCount = _eventCount;
			return true;
		}
	}

	return false;
}
Пример #24
0
File::File(const string& filename)
:   userLabels(userLabelCount_)
{
    ifstream is(filename.c_str(), ios::binary);
    if (!is)
        throw runtime_error("Unable to read file " + filename);

    short magic = readValue<short>(is);
    if (magic != (short)0xa101)
        throw runtime_error("Bad format: Magic number not found!");

    string finnigan = readString0(is);
    if (finnigan != "Finnigan")
        throw runtime_error("Bad format: Finnigan not found!");

    is.seekg(36);
    short versionNumber = readValue<short>(is); 
    XcaliburVersion version = interpretVersion(versionNumber);

    const int headSize = 1452;
    is.seekg(headSize);

    string unknown1 = readString(is);
    for (int i=0; i<userLabelCount_; i++)
        userLabels[i] = readString(is);
    string unknown2 = readString(is);

    if (version >= XcaliburVersion_2_0)
        is.seekg(60, ios::cur);

    int recordCount = readValue<int>(is); 
    readValue<int>(is); // unknown int value

    for (int i=0; i<recordCount; i++)
    {
        records.push_back(readRecord(is));
        if (version >= XcaliburVersion_2_0)
            is.seekg(60, ios::cur);
    }
}
Пример #25
0
int main(int argc, char const ** argv)
{
    // Check arguments.
    if (argc != 2) {
        std::cerr << "Wrong argument count!" << std::endl
                  << "USAGE: sequence_length SEQUENCE.fasta" << std::endl;
        return 1;
    }

    // Open file.
    std::fstream inF(argv[1], std::ios::in | std::ios::binary);
    if (!inF.good())
    {
        std::cerr << "ERROR: Could not open " << argv[1] << " for reading.\n";
        return 1;
    }

    // Create RecordReader.
    seqan::RecordReader<std::fstream, seqan::SinglePass<> > reader(inF);

    // Read sequence file and print sequence lengths.
    size_t total = 0;
    seqan::CharString id;
    seqan::CharString seq;
    while (!atEnd(reader))
    {
        if (readRecord(id, seq, reader, seqan::Fasta()) != 0)
        {
            std::cerr << "ERROR: Problem reading file " << argv[1] << ".\n";
            return 1;
        }

        std::cout << id << "\t" << length(seq) << "\n";
        total += length(seq);
    }
    std::cout << "sum\t" << total << std::endl;

    return 0;
}
Пример #26
0
int main(int argc, char const ** argv)
{
    if (argc != 2)
        return 1;  // Invalid number of arguments.

    // Open file and create RecordReader.
    std::fstream in(argv[1], std::ios::binary | std::ios::in);
    seqan::RecordReader<std::fstream, seqan::SinglePass<> > reader(in);

    // Read file record-wise.
    seqan::CharString id;
    seqan::Dna5String seq;
    while (!atEnd(reader))
    {
        if (readRecord(id, seq, reader, seqan::Fasta()) != 0)
            return 1;  // Could not read record from file.

        std::cout << id << "\t" << seq << "\n";
    }
    
    return 0;
}
Пример #27
0
void Functionality::loadEvent(EventStorage &tempEvent, string tempRecord)
{
	istringstream readRecord(tempRecord);
	string tempString;
	int tempDoneFlag;
	vector<string> eventParameters;

	for(int i = 0; i < 6; i++)
	{
		getline(readRecord, tempString, '#');
		if(i != 5)
			eventParameters.push_back(tempString);
		else
		{
			if(tempString[0] == '0')
				tempDoneFlag = 0;
			else
				tempDoneFlag = 1;
		}
	}

	tempEvent.storeUserInput(eventParameters, tempDoneFlag);
}
Пример #28
0
    void _readFirstRecord(MyGffRecord & record)
    {
        record.rID = record.INVALID_IDX;  // uninitialized

        bool found = false;
        while (!found && !atEnd(gffFileIn))
        {
            readRecord(record, gffFileIn);

            // Translate ref to idx from VCF.
            unsigned idx = 0;
            if (!getIdByName(idx, vcfMat.faiIndex, record.ref))
                throw MasonIOException("Reference name from GFF/GTF not in VCF!");
            record.rID = idx;

            if (empty(options.gffType) || (options.gffType == record.type))
            {
                found = true;
                break;
            }
        }
        if (!found)
            record.rID = seqan::maxValue<int>();
    }
Пример #29
0
void processBamFile(seqan::BamFileIn& bamFileIn, const TChromosomeFilter& chromosomeFilter, TOccurenceMap &occurenceMap, Statistics& stats)
{
    seqan::BamAlignmentRecord record;
    unsigned tagID = 0;
    std::set<BamRecordKey<WithBarcode>> keySet;

    while (!atEnd(bamFileIn))
    {
        readRecord(record, bamFileIn);
        if (atEnd(bamFileIn))
            break;
        ++stats.totalReads;
        if (chromosomeFilter.find(record.rID) != chromosomeFilter.end())
        {
            ++stats.filteredReads;
            continue;
        }
        const seqan::BamTagsDict tags(record.tags);
        if (seqan::findTagKey(tagID, tags, seqan::CharString("XM")))
        {
            __int32 tagValue = 0;
            extractTagValue(tagValue, tags, tagID);
            if (tagValue == 0)
                ++stats.couldNotMap;
            else
                ++stats.couldNotMapUniquely;
        }
        if (record.flag != 0x00 && record.flag != 0x10)
            continue;

        ++stats.totalMappedReads;
        const BamRecordKey<NoBarcode> pos(record);
        OccurenceMap::mapped_type &mapItem = occurenceMap[pos];
        ++mapItem;
    }
}
Пример #30
0
s32 GetCardData()
{
	u8 		**arr;
	s32 		size;

	if(!initialize())
		return 0;
	
	if(!selectFile(0xAA, 0x10))        
		return 0;   
	
	if(!readRecord(0x00, 0x18))       
		return 0;
	else
	{
		size = explode(&arr, pbRecvBuffer, '#');  
		strcpy(nik, arr[0]);
		strcpy(name, arr[1]);
		strcpy(saldo, arr[2]);
		strcpy(FingerData, arr[3]);
		
		return 1;
	}
}