Repository navigation
Expand file tree
/
Copy pathedit_fasta_ID_batch.pl
More file actions
executable file
·71 lines (62 loc) · 1.58 KB
/
Copy pathedit_fasta_ID_batch.pl
File metadata and controls
executable file
·71 lines (62 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /usr/bin/perl -w
use Bio::SeqIO;
use Data::Dumper;
# Adds annotations to the sequence ID of fasta file
# Input:
# $ARGV[0]= fasta file
# $ARGV[1]...$ARGV[n] = tsv annotations file ( 1st col= Seq id, 2nd col= Annotation)
# Annotations added in order separated by "|"
$fa_file= shift @ARGV;
# print @ARGV;
$file_num=0;
foreach $file(@ARGV){
$file_num++;
open(IN,$file); # File with info to edit IDs
while(<IN>){
chomp $_;
# @a=split(/\t/,$_);
# @b=split(/;/,$a[1]);
# $b[1]=~s/^\s+//g;
# $b[1]=~s/\s+$//g;
# $b[2]=~s/^\s+//g;
# $b[2]=~s/\s+$//g;
# $b[0]=~s/\s+$//g;
# $b[0]=~s/^\s+//g;
# $b[0]=~s/ /_/g;
# $id_hash{$file_num}{$a[0]}=$b[1].".".$b[2].".".$b[0];
@a=split(/\t/,$_);
$id_hash{$file_num}{$a[0]}=$a[1];
}
}
# print Dumper(\%id_hash);
$new=Bio::SeqIO->new(-file=>$fa_file, -format=>"fasta");
while($seq=$new->next_seq){
$i=$seq->id;
$s=$seq->seq;
# $i=~s/\.[0-9]+$//g;
# print $i;
# $i=~s/[A-Z]$//;
#@b=split(/\|/,$i);
# $seq_hash{$a[1]}=$s;
# @b=split(/\|/,$i);
# $a=($i=~/^>(.*?)\|/);
# print "$i\n";
# print "$b[3]\n";
print ">";
for ($j=1;$j<=$file_num;$j++){
if(defined $id_hash{$j}{$i}){
# if(defined $id_hash{$b[2]}){
# if(defined $id_hash{$a[1]} && (!(defined($print_hash{$a[1]})))){
# if($i=~/GT78/){
# if ($i=~/^consensus/){
print "$id_hash{$j}{$i}|";
# print ">$id_hash{$b[2]}\n$s\n";
# $print_hash{$a[1]}=1;
# print ">human_".$b[3]."|$id_hash{$b[3]}\n$s\n";
# print ">GT-A|consensus\n$s\n";
}else{
print "-|"
}
}
print "$i\n$s\n";
}