小编N1g*_*ght的帖子

如何使用kseq.h解析FASTA文件

我已经知道这个来自Heng Li的图书馆已经有一段时间了,但直到现在我还没有尝试过使用它,主要是因为到目前为止python已经足够快了.

以下是标题的链接:http://lh3lh3.users.sourceforge.net/kseq.shtml

当我尝试使用以下内容来解析fasta文件时,它返回-1作为序列行的长度.我查看了Li的代码,这似乎主要是为FASTQ解析而设计的,但他确实在他的网页上说它也支持FASTA格式.

这是我的代码:

#include <stdio.h>
#include <stdlib.h>
#include "kseq.h"  
// STEP 1: declare the type of file handler and the read() function  
KSEQ_INIT(FILE*, read)


int main(int argc, char** argv) {
    FILE* fp = fopen(argv[1], "r"); // STEP 2: open the file handler
    kseq_t *seq = kseq_init(fp); // STEP 3: initialize seq 

    int l;

    while ((l = kseq_read(seq)) >= 0) { // STEP 4: read sequence  
        printf("name: %s\n", seq->name.s);  
        if (seq->comment.l) printf("comment: %s\n", seq->comment.s);  
        printf("seq: %s\n", …
Run Code Online (Sandbox Code Playgroud)

c bioinformatics fasta

2
推荐指数
1
解决办法
1057
查看次数

标签 统计

bioinformatics ×1

c ×1

fasta ×1