Hello perl monks; How can I get the code to read from a file? It keeps asking me to enter sequence at line 4 but I need it to read from a file .txt file on my desktop.
How can I incorporate this into a code?
download# Open a .txt file open(seq1, "<seq1.txt") or die $!; #Assign open files to arrays my @seq1 = <seq1>; print "@seq1";
#!/usr/bin/env perl use warnings; use strict; # Open a .txt file open(seq1, "<seq1.txt") or die "Please enter two sequences as argumen +ts on the command line\n" unless @ARGV == 2; my ($orig, $comp) = map { uc } @ARGV; die "Please enter only ATCG sequences\n" if grep { /[^ATCG]/ } $orig, +$comp; die "Sorry, the two sequences you have just entered are of different l +engths." . "\nPlease try again on the command line.\n" if length $orig != length $comp; # $comp will transform back to $orig iff it is the reverse complement $comp =~ y/ATCG/TAGC/; if ($orig eq reverse $comp) { print "Yes, the two sequences are reverse-complement of each other +.\n"; exit; } else { die "Unfortunately, the two sequences are not reverse-complement.\ +n"; }
In reply to How to read from a .txt by stamp1982
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |