www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Strange behaviour with mmfile

reply bioinfornatics <bioinfornatics fedoraproject.org> writes:
Dear,

Why when i try to read this file:

------------Input file-------------------------
$ cat little.fastq=20
 H8:C16L5ACXX:8:1101:1168:2103/1
TCTGAAGGCATGCTGCAATTGTGAATGGCAGAAATGT
+
?  DD>DBDAFDF 4CFGICFHHECHEEBF;E FFFG
 H8:C16L5ACXX:8:1101:1223:2104/1
CTCACTTTTGTACTTTAGACAAGCGCTTTTAGTAGTGCT
+
  ;DD;?DHFFHFG9FAFCEGFGBFE1EFFGFGGHG9D*
 H8:C16L5ACXX:8:1101:1166:2142/1
ATCTGGGAAGACGCCGCCGGGTTCAAATCACCTTGGTCGGCATCGTCGATCCGC
+
;=3D?DDDDD3C??) :E1CDD)?B?B<99BB8=3D<8)8.=3DA88<8)56;9/>2=3D??


By using mmfile ubyte given do not corresponding to the letter.
By example for   i expect 64 but i got 127


---------------Result-----------------------
$ ./test_mmap little2.fastq
127 =7F
69 E
76 L
70 F
2 =02
1 =01
1 =01
0=20
0=20
0=20
0=20
0=20
0=20
0=20
0=20
0=20
2 =02
0=20
62 >
0=20
=E2=80=A6 and that continue

Big thanks

Note i have try with both ldc and gdc
Jan 28 2013
parent reply bioinfornatics <bioinfornatics fedoraproject.org> writes:
I missed to show the code

$ cat test_mmap.d
import std.stdio;
import std.mmfile;

void main(string[] args ){
    MmFile m =3D new MmFile( args[0] );
    foreach( ulong c; 0..m.length )
        writeln( m[c], " ", cast(dchar) m[c] );
}
Jan 28 2013
parent reply "nazriel" <spam dzfl.pl> writes:
On Tuesday, 29 January 2013 at 00:49:07 UTC, bioinfornatics wrote:
 I missed to show the code

 $ cat test_mmap.d
 import std.stdio;
 import std.mmfile;

 void main(string[] args ){
     MmFile m = new MmFile( args[0] );
     foreach( ulong c; 0..m.length )
         writeln( m[c], " ", cast(dchar) m[c] );
 }
MmFile m = new MmFile( args[0] ); ? Didn't you mean args[1] or something? Because now you are reading your binary file and output is correct, its spits out elf header info. My guess is your are passing file with DNA (or whatever it is) via command line arguments
Jan 28 2013
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Jan 29, 2013 at 05:46:49AM +0100, nazriel wrote:
 On Tuesday, 29 January 2013 at 00:49:07 UTC, bioinfornatics wrote:
I missed to show the code

$ cat test_mmap.d
import std.stdio;
import std.mmfile;

void main(string[] args ){
    MmFile m = new MmFile( args[0] );
    foreach( ulong c; 0..m.length )
        writeln( m[c], " ", cast(dchar) m[c] );
}
MmFile m = new MmFile( args[0] ); ? Didn't you mean args[1] or something?
[...] Good catch! I looked at the OP's code and didn't notice that. :) In D, args[0] is the name of the program, and args[1] is the first argument, etc.. T -- Nearly all men can stand adversity, but if you want to test a man's character, give him power. -- Abraham Lincoln
Jan 28 2013
parent "bioinfornatics" <bioinfornatics fedoraproject.org> writes:
On Tuesday, 29 January 2013 at 06:37:11 UTC, H. S. Teoh wrote:
 On Tue, Jan 29, 2013 at 05:46:49AM +0100, nazriel wrote:
 On Tuesday, 29 January 2013 at 00:49:07 UTC, bioinfornatics 
 wrote:
I missed to show the code

$ cat test_mmap.d
import std.stdio;
import std.mmfile;

void main(string[] args ){
    MmFile m = new MmFile( args[0] );
    foreach( ulong c; 0..m.length )
        writeln( m[c], " ", cast(dchar) m[c] );
}
MmFile m = new MmFile( args[0] ); ? Didn't you mean args[1] or something?
[...] Good catch! I looked at the OP's code and didn't notice that. :) In D, args[0] is the name of the program, and args[1] is the first argument, etc.. T
Oh yes stupid error thanks LOL
Jan 29 2013