ShortRead- how to edit the id in a fastq
1
0
Entering edit mode
newmanss • 0
@newmanss-7190
Last seen 4.6 years ago
United States

I need to edit the fragment IDs in a MiSeq fastq file. I'm using ShortRead to load the fastq and I've successfully managed to insert the substring needed  but I can't use my code to substitute the new ID into the id slot of my fastq.  Here is my current code:

fqr <- sub(" ",barcodestr, ShortRead::id(fqr))

In this case, the result is a list with only the ids.  I've lost the reads and quality values.

 ShortRead::id(fqr)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘id’ for signature ‘"character"’
> head(fqr)
[1] "M00967:43:000000000-A3JHG:1:1101:17304:1428;barcodelabel=F3D8; 1:N:0:196"
[2] "M00967:43:000000000-A3JHG:1:1101:17368:2241;barcodelabel=F3D8; 1:N:0:196"
[3] "M00967:43:000000000-A3JHG:1:1101:15330:2396;barcodelabel=F3D8; 1:N:0:196"
[4] "M00967:43:000000000-A3JHG:1:1101:11983:2593;barcodelabel=F3D8; 1:N:0:196"
[5] "M00967:43:000000000-A3JHG:1:1101:20789:2650;barcodelabel=F3D8; 1:N:0:196"
[6] "M00967:43:000000000-A3JHG:1:1101:12794:3085;barcodelabel=F3D8; 1:N:0:196"

I've also tried: 

fqr@id <- sub(" ",barcodestr, ShortRead::id(fqr))
Error in checkAtAssignment("ShortReadQ", "id", "character") :
  assignment of an object of class “character” is not valid for @‘id’ in an object of class “ShortReadQ”; is(value, "BStringSet") is not TRUE

Please suggest how I access and overwrite the ID in my fastq.

Many thanks,  Susan

 

ShortRead • 2.1k views
ADD COMMENT
0
Entering edit mode
@valerie-obenchain-4275
Last seen 7 months ago
United States

Hi Susan,

The id in a ShortReadQ class must be a BStringSet object. The output of sub() is a character. The problem is that you are trying to put a character in a slot that expects a BStringSet.

Try

myids <- sub("", barcodestr, ShortRead::id(fqr))
BStringSet(myids)

and then replacing the ids. It looks like there isn't an id<- replacement function and this may be by design. Martin may suggest another approach.

Valerie

ADD COMMENT
0
Entering edit mode

Thank you.  I will try that strategy.  A moment ago, before I checked for an answer, I tried one more approach that appears to work. 

fqr@id[ ] <- sub(" ",barcodestr, ShortRead::id(fqr))

then to check-

 head(fqr@id)
  A BStringSet instance of length 6
    width seq
[1]    72 M00967:43:000000000-A3JHG:1:1101:17304:1428;barcodelabel=F3D8; 1:N:0:196
[2]    72 M00967:43:000000000-A3JHG:1:1101:17368:2241;barcodelabel=F3D8; 1:N:0:196
[3]    72 M00967:43:000000000-A3JHG:1:1101:15330:2396;barcodelabel=F3D8; 1:N:0:196
[4]    72 M00967:43:000000000-A3JHG:1:1101:11983:2593;barcodelabel=F3D8; 1:N:0:196
[5]    72 M00967:43:000000000-A3JHG:1:1101:20789:2650;barcodelabel=F3D8; 1:N:0:196
[6]    72 M00967:43:000000000-A3JHG:1:1101:12794:3085;barcodelabel=F3D8; 1:N:0:196
ADD REPLY
0
Entering edit mode

Generally it's very bad practice to access slots directly. The recommended way to update these objects is simply to create a new version -- fqr <- ShortReadQ(sread(fqr), quality(frq), BStringSet(sub("", barcodestr, id(fqr))))

ADD REPLY

Login before adding your answer.

Traffic: 217 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