CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [lostagain] sub and hashes: Edit Log



Chris Charley
User

Nov 21, 2012, 4:01 PM


Views: 1333
Re: [lostagain] sub and hashes

Here is a small example of fasta parsing, but I should state that I'm by no means an expert or even that knowledgable using the Bio::Seq module and the Bio::SeqIO module.


Code
  #!/usr/bin/perl   
use strict;
use warnings;
use Bio::SeqIO;

my $in = Bio::SeqIO->new( -file => "input1.txt" ,
-format => 'fasta');

while ( my $seq = $in->next_seq() ) {
my $fasta = $seq->seq;
while ($fasta =~ /AATT/ig) {
print pos($fasta), ' ', $seq->id, "\n";
}
}

__END__
*** contents of input1.txt
>chr1
AACCCCCCCCTCCCCCCGCTTCTGGCCACAGCACTTAAACACATCTCTGC
CAAACCCCAAAAACAAAGAACCCTAACACCAGCCTAACCAGATTTCAAAT
TTTATCTTTAGGCGGTATGCACTTTTAACAAAAAANNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
GCCCATCCTACCCAGCACACACACACCGCTGCTAACCCCATACCCCGAAC
CAACCAAACCCCAAAGACACCCCCCACAGTTTATGTAGCTTACCTCNNNN
>chrM
GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCAT
TTGGTATTTTCGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTG
GAGCCGGAGCACCCTATGTCGCAGTATCTGTCTTTGATTCCTGCCTCATT
CTATTATTTATCGCACCTACGTTCAATATTACAGGCGAACATACCTACTA
AAGTGTGTTAATTAATTAATGCTTGTAGGACATAATAATAACAATTGAAT
GTCTGCACAGCCGCTTTCCACACAGACATCATAACAAAANAATTTCCACC
>GJKKTUG01DYDGC
GGGTATTCCTTCTCCACCTTGCAGCTAACATCAGTGTTTCGTCTACTCAAGCACGCCAAC
ACGCCCTAGAGCGCCCTGTCCAGGGGATGGCAACCAACTCTGACCCTGCAAGTGCAGCAG
ACATGAGGAATACAAACTACAATCTTTTACTTGATGATGCAATGCCGGACAAACTCTAGA
>F0Z7V0F01EDB3V
AAGGCGAGNGGTATCACGCAGTAAGTTACGGTTTTCGGGTAACGCGTCNGNGGNACTAAC
CCACGGNGGGTAACCCGTCNCTACCGGTATAGGACTAAGGTTACCGGAACGTCGTGGGGT
ACCCCCCGGACGGGGACCGTCCCCTCATANAGTCAACNGTNTGAGATGGACTAACTCAAA
CCTAGTTTCAAGTACTATTTAACTTACTTACGTTACCCGTAATTTCGGCGTTTAGAGGCG


Output from the sample 'input1.txt' fasta file.


Code
  C:\Old_Data\perlp>perl t33.pl   
101 chr1
213 chrM
217 chrM
246 chrM
294 chrM
224 F0Z7V0F01EDB3V


Most likely, someone else has already solved your problem. There is a How To, especially the How To for Beginners and for SeqIO. There is also
bedtools
and other software developed to solve problems in Genomics.


(This post was edited by Chris Charley on Nov 21, 2012, 5:28 PM)


Edit Log:
Post edited by Chris Charley (User) on Nov 21, 2012, 5:25 PM
Post edited by Chris Charley (User) on Nov 21, 2012, 5:28 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives