且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用perl查找DNA序列中的核苷酸

更新时间:2022-10-14 18:18:49

my $nucleotide = substr $DNA, $po, 3;

这将从位置$po的3个核苷酸直到$po+2,并将其分配给$nucleotide.

I have the sequence DNA and I want to find nucleotide of the sequence at the position which was chosed by people. Below is the example:

Enter the sequence DNA: ACTAAAAATACAAAAATTAGCCAGGCGTGGTGGCAC (the length of sequence is 33) Enter the position: (12)

I hope the result is the position number 12 the nucleotides are AAA.

I have no problem finding the amino acid of the position. Below is the current code I have.

print "ENTER THE FILENAME OF THE DNA SEQUENCE:= ";
$DNAfilename = <STDIN>;
chomp $DNAfilename;
unless ( open(DNAFILE, $DNAfilename) ) {
  print "Cannot open file \"$DNAfilename\"\n\n";
}
@DNA = <DNAFILE>;
close DNAFILE;
$DNA = join( '', @DNA);
print " \nThe original DNA file is:\n$DNA \n";
$DNA =~ s/\s//g;

print" enter the number ";
$po=<STDIN>;

@pos=$DNA;
if ($po>length($DNA)) 
{
  print" no data";
}

else 
{
  print " @pos\n\n";
}

Please advice how can I find the position at the DNA sequence.

my $nucleotide = substr $DNA, $po, 3;

This will take the 3 nucleotides from positions $po upto $po+2 and assign it to $nucleotide.