ダウンロード
#!/usr/bin/perl -w use strict; use warnings; my $fastafilename = "Example_cDNA_fol/Seq_Human.txt"; my @fastadata = ( ); unless( open(FASTAFILE, $fastafilename) ) { print STDERR "Cannot open file $fastafilename\n"; exit; } @fastadata = <FASTAFILE>; close FASTAFILE; # print "@fastadata\n"; my $sequence = ''; my $nameline = ''; my $gname0 = ''; my $gname = ''; my $tmp = ''; my $firstline = 1; foreach my $line (@fastadata) { if ($line =~ /^>ENST/) { $nameline = $line; if ($nameline !~ /ENSG/) { print "error ENSG was not found\n"; } # Now get the gene name ($tmp, $gname) = split /gene:/, $nameline; chomp ($gname); if ($firstline eq 1) { $gname0 = $gname; print "I found a gene $gname\n"; } $firstline = 0; if ($gname0 ne $gname) { print "I found a new gene $gname\n"; open (GENESEQ, ">$gname0") || die "error when opening $gname0\n"; print GENESEQ ">$gname0\n$sequence\n"; close GENESEQ; $gname0 = $gname; $sequence = ''; } # print "|$tmp|, \n|$gname|\n"; } else { chomp($line); $sequence .= $line; print "|$sequence|\n"; } } open (GENESEQ, ">$gname") || die "error when opening $gname\n"; print GENESEQ ">$gname\n$sequence\n"; close GENESEQ; exit; |
|||
|