write ab1 files
0
0
Entering edit mode
tmolosh • 0
@tmolosh-14015
Last seen 6.4 years ago

Hi,

I am playing around with manipulation of ab1 file data imported into R with sangerseqR.

sangerseqR can read.abif() and do nice things with the data within R, but i cannot figure out any way to export the modified data into a new ab1 file for other tools to use.

Has anyone else figured this out, or can anyone make suggestions?

 

Thanks,

Tom

sangerseqr sequencing abi • 1.8k views
ADD COMMENT
0
Entering edit mode

Fragman and seqinr have their own (identical?, different from sangerseqR) read.abif fxns. Trying to use this as a model for the reverse process I don't get anywhere ... any suggestions? Here is some of what i have done:

##### read binary as in Fragman's read.abif function #####

fh <- file("input.ab1", open="rb")
fh
                        description                      class
                          "input.ab1"                      "file"
                                 mode                       text
                                 "rb"                   "binary"
                              opened                   can read
                            "opened"                      "yes"
                          can write
                                 "no"
rd <- readBin(fh, what="raw", n=1.2 *file.info("pGem-CP1-1768794_H12.ab1")$size), endian="little")

# rd is hexadecimal

##### check what was imported #####

summary(rd)
    Length  Class   Mode
    291025    raw    raw

##### import the data as it would be worked on #####

library(Fragman)

abif <- read.abif("input.ab1")
summary(abif)
              Length Class      Mode
    Header     10    -none-     list
    Directory   7    data.frame list
    Data      130    -none-     list

##### try to write binary with the imported data #####

newfh <- file("new.ab1", "wb")
newfh
    description       class        mode        text      opened    can read
      "new.ab1"      "file"        "wb"    "binary"    "opened"        "no"
      can write
          "yes"

writeBin(abif, newfh, endian="little")
    Error in writeBin(abif, newfh, endian = "little") :
      can only write vector objects
writeBin(as.vector(abif), newfh, endian="little")
    Error in writeBin(as.vector(abif), newfh, endian = "little") :
      can only write vector objects
writeBin(as.vector(unlist(abif)), newfh, endian="little")
close(newfh)

# ab1 file is written but cannot be read as ab1

input.ab1 ~ 291kb newer.ab1 ~ 503kb

ADD REPLY

Login before adding your answer.

Traffic: 716 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6