User Tools

Site Tools


Sidebar

This is the sidebar. Without it, the main text is too wide!


2019년 11월 교육 자료


2022년 교육안

custom_perl_scripts

my_rename1.pl

#!/usr/bin/perl
#
open ALL, $ARGV[0] or die "Can't open file $ARGV[0]!";
while (<ALL>) {
    chomp;
    next unless /^(GCF|GCA)/;
    my @data = split /\t/, $_;
    $data[8] =~ s/strain=//; # infraspefic_name
    my $strain = $data[8];
    $data[7] =~ s/ $strain$//; # remove redundant strain name
    my $name = $data[7] . ' ' . $data[8];
    $name .= $data[15] if $name =~ /^\S+ \S+ $/; # add asm_name if required
    $name =~ s/:/-/g;
    $name =~ s/\s+/_/g;
    $name =~ s/;.*$//;     # remove semicolon and following information
    $name =~ s/\//_/;
    $name =~ s/_$//;
    my @temp = split /\//, $data[19];
    $key = pop @temp;
    $key2name{$key} = $name;
    print $key, "\t", $name, "\n";
}

my_rename2.pl

#!/usr/bin/perl
#
# $ARGV[0] : id2name file
#    GCF_000015065.1_ASM1506v1       Bt_str._Al_Hakam
#    GCF_000092165.1_ASM9216v1       Bt_BMB171
#    ...
# $ARGV[1] : fna file 
#    GCF_000015065.1_ASM1506v1_genomic.fna
#

open ALL, $ARGV[0] or die "Can't open file $ARGV[0]!";
while (<ALL>) {
    chomp;
    my @data = split /\t/, $_;
    $key2name{$data[0]} = $data[1];
}

my @temp = split /_/, $ARGV[1];
my $suffix = pop @temp;
my $accession = $temp[0] . '_' . $temp[1];
$suffix =~ /^.+\.(.+)$/;
$end = $1;
$key = join '_', @temp;

#print $key, " ", $key2name{$key}, " ", $end, "\n";
$file = $key2name{$key} . '_' . $accession . '.' . $end;
print "$ARGV[1] ===> $file\n";
system("cp $ARGV[1] $file") if defined $file;
custom_perl_scripts.txt · Last modified: 2021/03/17 13:09 (external edit)