COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
VectorIOPermute.cpp
Go to the documentation of this file.
1#include <mpi.h>
2#include <sys/time.h>
3#include <iostream>
4#include <functional>
5#include <algorithm>
6#include <vector>
7#include <sstream>
8#include "CombBLAS/CombBLAS.h"
9
10using namespace std;
11using namespace combblas;
12
13#define myidlen 35
14#define myseqlen 150
15
16template <unsigned int IDLEN, unsigned int SEQLEN>
18{
19public:
20 ShortRead(){ id[0] = '\0'; seq[0] = '\0'; qual[0] = '\0'; };
21 ShortRead(const string & s_id, const string & s_seq, const string & s_qual)
22 {
23 s_id.copy(id, IDLEN);
24 s_seq.copy(seq, SEQLEN);
25 s_qual.copy(qual, SEQLEN);
26 id[IDLEN] = '\0';
27 seq[SEQLEN] = '\0';
28 qual[SEQLEN] = '\0';
29
30 }
31 template <unsigned int NS_IDLEN, unsigned int NS_SEQLEN>
32 friend ostream& operator<<( ostream& os, const ShortRead<NS_IDLEN,NS_SEQLEN> & sread);
33
34private:
35 char id[IDLEN+1]; // (+1)s are for null termination
36 char seq[SEQLEN+1];
37 char qual[SEQLEN+1];
38
39 template <typename IT,unsigned int NS_IDLEN, unsigned int NS_SEQLEN> // NS: no-shadow
41};
42
43template <unsigned int IDLEN, unsigned int SEQLEN>
44ostream& operator<<(ostream& os, const ShortRead<IDLEN, SEQLEN> & sread )
45{
46 os << sread.id << " " << sread.seq << " " << sread.qual << endl;
47 return os;
48};
49
50
51template <class IT, unsigned int IDLEN, unsigned int SEQLEN>
53{
54public:
57
59 {
60 return MPIType< ShortRead<IDLEN,SEQLEN> >(); // utilize the MPI type cache
61 }
62
64 {
65 size_t entryLength = fread (&ind,sizeof(ind),1,rFile); // read the index first
67 if(entryLength != 2)
68 cout << "Not enough bytes read in binaryfill " << endl;
69 }
70 size_t entrylength() { return sizeof(ShortRead<IDLEN,SEQLEN>); }
71
72 template <typename c, typename t>
73 ShortRead<IDLEN,SEQLEN> read(std::basic_istream<c,t>& is, IT ind)
74 {
75 string s_id, s_seq, s_qual, s_null;
76 getline (is,s_id);
78 getline (is,s_null); // basically the '+' sign
80
82 }
83
84 template <typename c, typename t>
85 void save(std::basic_ostream<c,t>& os, const ShortRead<IDLEN,SEQLEN> & tw, IT ind)
86 {
87 // make it compatible with read...
88 }
89};
90
91
92
93int main(int argc, char* argv[])
94{
95 int nprocs, myrank;
96 MPI_Init(&argc, &argv);
99
100 if(argc < 4)
101 {
102 if(myrank == 0)
103 {
104 cout << "Usage: ./VectorIOPermute <VectorFile>" << endl;
105 cout << "<VectorFile> is a binary file" << endl;
106 }
107 MPI_Finalize();
108 return -1;
109 }
110 {
111
113 ShortReads.ReadDistribute(string(argv[1]), 0, ShortReadSaveHandler<int64_t, myidlen, myseqlen>(), true); // read it from binary file in parallel
114
115
116 }
117 MPI_Finalize();
118 return 0;
119}
int main()
Definition Driver.cpp:12
void binaryfill(FILE *rFile, IT &ind, ShortRead< IDLEN, SEQLEN > &val)
ShortRead< IDLEN, SEQLEN > getNoNum(IT ind)
ShortRead< IDLEN, SEQLEN > read(std::basic_istream< c, t > &is, IT ind)
void save(std::basic_ostream< c, t > &os, const ShortRead< IDLEN, SEQLEN > &tw, IT ind)
MPI_Datatype getMPIType()
friend ostream & operator<<(ostream &os, const ShortRead< NS_IDLEN, NS_SEQLEN > &sread)
ShortRead(const string &s_id, const string &s_seq, const string &s_qual)
int nprocs
Definition comms.cpp:55
std::ofstream & operator<<(std::ofstream &outfile, const SpMat< UIT, UNT, UDER > &s)
Definition SpMat.cpp:201
Collection of Generic Sequential Functions.