1

行を連結するにはPerlスクリプトが必要です..

1000 以上の遺伝子名 (>pmpI) とその機能 (多形性外膜タンパク質) が別の行にあり、遺伝子の機能を遺伝子名の近くに結合したいと考えています。後で参照できるように視覚化して保存します。

例: ファイルの内容は次のようになります

>pmpG
 polymorphic outer membrane protein
>pmpH
 polymorphic outer membrane protein
>CTA_0953
 hypothetical protein
>pmpI
 polymorphic outer membrane protein

私は手動でExcelで手動でやろうとしましたが、多くのファイルでは不可能なので、プログラマーの助けを借りることを考えました..

行を連結するにはPerlスクリプトが必要です

プログラムの出力は次のようになります。

>pmpG      polymorphic outer membrane protein
>pmpH      polymorphic outer membrane protein
>CTA_0953  hypothetical protein
>pmpI      polymorphic outer membrane protein
4

2 に答える 2

0

いくつかの説明コメント付き...

#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

# Store the current line
my $line;
while (<DATA>) {
  # Remove the newline
  chomp;
  # If the line starts with '>'
  if (/^>/) {
    # Output the current $line
    # (if we have one)
    say $line if $line;
    # Set $line to this line
    $line = $_;
  } else {
    # Append this line to $line
    $line .= "\t$_";
  }
}

# Output the current line
say $line;

__DATA__
>pmpG
 polymorphic outer membrane protein
>pmpH
 polymorphic outer membrane protein
>CTA_0953
 hypothetical protein
>pmpI
 polymorphic outer membrane protein
于 2016-03-10T13:40:40.273 に答える