Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. File1:
  2. >Seq1
  3. ABCDEFGH
  4. >Seq2
  5. RNADIMSEQ
  6. >Seq6
  7. XYZ
  8.  
  9. File2:
  10. >Seq3
  11. ABCDEFGH
  12. >Seq4
  13. RNADIMSEQ
  14.  
  15. Output:
  16. >Seq1 >Seq3
  17. >Seq2 >Seq4
  18. >Seq6 Not found
  19.  
  20. %hash=();
  21. open(out, ">Output.txt");
  22. open(sbjt, "File1.fasta") or die "File not found"; #Bigger file
  23. $count =0;
  24. while(<sbjt>)
  25. {
  26. chomp;
  27. if($_ =~ m/^w+/)
  28. {
  29. $hash{$previous} = $_ ;
  30. #print "$previousn";
  31. }
  32. else
  33. {
  34. $previous = $_;
  35. }
  36. $count++ ;
  37. }
  38. close sbjt;
  39. #print "$hash{$previous}";
  40.  
  41. %dash=();
  42. $previous = undef;
  43. open(query, "File2.fasta") or die "File not found"; #smaller
  44. while(<query>)
  45. {
  46. chomp;
  47. if($_ =~ m/^w+/)
  48. {
  49. $dash{$previous} = $_ ;
  50. #print "$previousn";
  51. }
  52. else
  53. {
  54. $previous = $_;
  55. }
  56. }
  57. close query;
  58.  
  59. foreach $key (keys %dash)
  60. {
  61. foreach $temp (keys %hash)
  62. {
  63. if($hash{$temp} eq $dash{$key})
  64. {
  65. push(@new_array, $temp);
  66. }
  67. next; #added
  68. }
  69. if(scalar @new_array>0)
  70. {
  71. print out "$keyt@new_arrayn";
  72. }
  73. else
  74. {
  75. print out "$keytNot foundn";
  76. }
  77. @new_array=();
  78. }
  79.  
  80. my $end_run = time();
  81. my $run_time = $end_run - $start_run;
  82. print "Job took $run_time secondsn";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement