File: testWriteSFF.cc

package info (click to toggle)
srf 0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 3,884 kB
  • ctags: 160
  • sloc: cpp: 1,158; sh: 558; makefile: 37
file content (79 lines) | stat: -rw-r--r-- 1,700 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <stddef.h>
#include <SRF_util.hh>
#include <SRF_File.hh>
#include <SRF_ReadSet.hh>
#include <SRF_Container.hh>

using namespace std;

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <io_lib/Read.h>
#include <io_lib/misc.h>
#include <io_lib/hash_table.h>
#include <io_lib/ztr.h>
#include <io_lib/sff.h>
#include <zlib.h>

template <class T>
std::string SRF_to_string(T t, std::ios_base & (*f)(std::ios_base&))
{
  std::ostringstream oss;
  oss << f << t;
  return oss.str();
}   

main(int argc, char* argv[])
{
    if ( argc != 3 )
    {
        cout << "Usage: sffWriter <SFF file> <output file>\n";
        exit(1);
    }

    SRF_File::openType mode = SRF_File::openTypeWrite;
    SRF_File file( argv[2], mode );

    SRF_Container container;

    container.setup( "Test",
                     "0.0" );

    container.write( file.getFile() );

    SRF_ReadSet newReadSet;
    newReadSet.setup( "Test", "" );

    int readIdCounter = 0;

    int a,b,c,d;
    string str, seq;

    std::vector<ztr_t> ztrBlobs;
    std::vector<std::string> readIds;
// open fasta
//    std::ifstream fastaInput;
//    fastaInput.open(argv[1], std::ios::in );
    Read* read = NULL;
    mFILE* mf = mfopen(argv[1], "r");
    while ( ( read = mfread_sff( mf ) ) != NULL )
    {
        string readId;
        readId = SRF_to_string<int>(readIdCounter, std::dec);
        ztr_t* ztr = NULL;
        ztr = SRF_output_ztr( read );
        ztrBlobs.push_back( *ztr );
        readIds.push_back( readId );
        readIdCounter++;
    }
    newReadSet.write( file.getFile(), ztrBlobs, readIds );
}