Domanda

Fondamentalmente, un file Genbank consiste sulle voci geni (annunciate da "Gene" seguite dalla corrispondente voce "CDS" (solo una per genice) come i due che mostro qui qui sotto. Mi piacerebbe ottenere il prodotto locus_tag vs in aTab -imited Due colonne file. 'Gene' e 'CDS' sono sempre preceduti e seguiti da spazi.

Una domanda precedente ha suggerito uno script.

Il problema è che sembra che, poiché "Prodotto" ha un carattere a volte "/ 'nel suo nome, è il suo conflitto con questo script, che, per quanto posso capire, sta usando' / 'come separatore di campo da memorizzareinformazioni in un array?

Vorrei risolvere questo, o modificando questo script o costruendo altro.

perl -nE'
  BEGIN{ ($/, $") = ("CDS", "\t") }
  say "@r[0,1]" if @r= m!/(?:locus_tag|product)="(.+?)"!g and @r>1
' file


 gene            complement(8972..9094)
                 /locus_tag="HAPS_0004"
                 /db_xref="GeneID:7278619"
 CDS             complement(8972..9094)
                 /locus_tag="HAPS_0004"
                 /codon_start=1
                 /transl_table=11
                 /product="hypothetical protein"
                 /protein_id="YP_002474657.1"
                 /db_xref="GI:219870282"
                 /db_xref="GeneID:7278619"
                 /translation="MYYKALAHFLPTLSTMQNILSKSPLSLDFRLLFLAFIDKR"
 gene            68..637
                 /locus_tag="HPNK_00040"
 CDS             68..637
                 /locus_tag="HPNK_00040"
                 /codon_start=1
                 /transl_table=11
                 /product="NinG recombination protein/bacteriophage lambda
                 NinG family protein"
                 /protein_id="CRESA:HPNK_00040"
                 /translation="MIKPKVKKRKCKCCGGEFKSADSFRKWCSAECGVKLAKIAQEKA
                 RQKAIEKRNREERAKIKATRERLKSRSEWLKDAQAIFNEYIRLRDKDEPCISCRRFHQ
                 GQYHAGHYRTVKAMPELRFNEDNVHKQCSACNNHLSGNITEYRINLVRKIGAERVEAL
                 ESYHPPVKWSVEDCKEIIKTYRAKIKELK"
.

È stato utile?

Soluzione

Come il tuo file Genbank di esempio è stato incompleto, sono andato online per trovare un file di esempio che potrebbe essere utilizzato in un esempio, e ho trovato Questo file .

Usando questo codice e Bio::GenBankParser Modulo, è stato analizzato indovinare quali parti della struttura che eri dopo. In questo caso, "Caratteristiche" che conteneva sia un campo locus_tag che un campo product.

use strict;
use warnings;
use feature 'say';
use Bio::GenBankParser;

my $file = shift;
my $parser = Bio::GenBankParser->new( file => $file );
while ( my $seq = $parser->next_seq ) {
    my $feat = $seq->{'FEATURES'};
    for my $f (@$feat) {
        my $tag = $f->{'feature'}{'locus_tag'};
        my $prod = $f->{'feature'}{'product'};
        if (defined $tag and defined $prod) {
            say join "\t", $tag, $prod;
        }
    }
}
.

Uso:

perl script.pl input.txt > output.txt
.

Uscita:

MG_001  DNA polymerase III, beta subunit
MG_470  CobQ/CobB/MinD/ParA nucleotide binding domain-containing protein
.

L'uscita dal tuo liner per lo stesso ingresso sarebbe:

MG_001  DNA polymerase III, beta subunit
MG_470  CobQ/CobB/MinD/ParA nucleotide binding
                     domain-containing protein
.

Supponendo naturalmente che si aggiunge il modificatore /s al regex per spiegare le voci multilinea (che leeduhem sottolineato I commenti):

m!/(?:locus_tag|product)="(.+?)"!sg
#                                ^---- this
.

Altri suggerimenti

Having read your duplicated question http://www.biostars.org/p/94164/ (please don't double post like this), here's a minimal Biopython answer:

import sys
from Bio import SeqIO
filename = sys.argv[1] # Takes first command line argument input filename
for record in SeqIO.parse(filename, "genbank"):
    for feature in record.features:
        if feature.type == "CDS":
            locus_tag = feature.qualifiers.get("locus_tag", ["???"])[0]
            product = feature.qualifiers.get("product", ["???"])[0]
            print("%s\t%s" % (locus_tag, product))

With minor changes you can write this out to a file instead.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top