Fq file to table
        3 
    
    
    
        
        
        
        
            
                
                
                    
                        
                    
                
                    
                        Hello all!
I am looking for different ways to convert fq file to tabular format. I mean from this:
@name
AGTC
some_text
HHJH
to this:
@some_name   AGTC   +   HHHH
every four strings in one row
How can I do it with Python/R and in bash/awk?
                    
                 
                 
                
                
                    
                    
    
        
        
            fastq
         
        
    
    
        • 1.6k views
    
 
                
                 
            
            
         
     
 
     
    
        
            
        
            
                
    
    
    
    
        
        
        
        
            
                
                
                    
                        
                    
                
                    
                        In Python:
#!/usr/bin/env python
import sys
record = []
for line in sys.stdin:
    record.append(line.rstrip())
    if len(record) == 4:
        sys.stdout.write('{}\n'.format('\t'.join(record)))
        record.clear()
Then: python ./linearize_fastq.py < in.fastq > out.txt
                    
                 
                 
                
                
                 
            
            
         
     
 
         
        
            
                
    
    
    
    
        
        
        
        
            
                
                
                    
                        
                    
                
                    
                        $ awk -v OFS="\t" -v RS="@" 'NR > 1 {print "@"$1,$2,$3,$4}' test.fq
$ awk -v OFS="\t" -v RS="@" 'NR > 1 {gsub("\n","\t"); print "@"$0}' test.fq
$ bioawk -c fastx '{print $seq, $name, $qual}' test.fq
$ seqkit fx2tab test.fq
$ tr -s "\n" "\t" < test.fq | sed -r 's/\t@/\n@/g'
 
                 
                
                
                 
            
            
         
     
 
         
        
 
    
    
        
            
                  before adding your answer.
         
    
    
         
        
            
        
     
    
    Traffic: 4438 users visited in the last hour