나는 뉴클레오타이드 문자열에 3 개의 뉴클레오타이드의 반복 패턴을 찾기 위해 큰 입력을 받았다. 그 요구 사항은 반복이 그것을위한 정규식을 만들어 연속적으로 7 번 발생한다는 것이다. 조건부로 여러 정규식에 입력을 적용 하시겠습니까?
my $regex1 = qr/(([ACGT]{3}) \2{6,})/x;
가 나는 7
의 행에서 10 행뿐만 아니라 4 2 nucs를 검색 확장하는 방법을 이해하지만 코드를 확장하고자하는 사용자가 할 수 있도록 그들의 입력 파일을 가리키고 위의 정규식뿐만 아니라 다른 두 개의 검색을 위해 만들 필요가있는 두 개의 다른 정규식을 확인합니다.
EDIT : 입력 파일에 위의 것과 같은 여러 정규식을 적용하려면 어떻게해야합니까? 나는 (해시 기호로 기절) 코드
여기
print "Please specify the file location (DO NOT DRAG/DROP files!) then press ENTER:\n";
$seq = <STDIN>;
#Remove the newline from the filename
chomp $seq;
#open the file or exit
open (SEQFILE, $seq) or die "Can't open '$seq': $!";
#read the dna sequence from the file and store it into the array variable @seq1
@seq1 = <SEQFILE>;
#Close the file
close SEQFILE;
#Put the sequence into a single string as it is easier to search for the motif
$seq1 = join('', @seq1);
#Remove whitespace
$seq1 =~s/\s//g;
#Count of number of nucleotides
#Initialize the variable
$number = 0;
$number = length $seq1;
#Use regex to say "Find 3 nucelotides and match at least 6 times
# qr(quotes and compiles)/(([nucs]{number of nucs in pattern}) \2{number of repeats,}/x(permit within pattern)
my $regex1 = qr/(([ACGT]{3}) \2{6,})/x;
#my $regex = qr/(([ACGT]){2}) \2{9,})/x;
#my $regex2 = qr/(([ACGT]{4}) \2{6,})/x;
#Tell program to use $regex on variable that holds the file
$seq1 =~ $regex1;
#Now print the results to screen
#This will need to change to printing to a file (WHAT KIND OF FILE?)in the following manner :site, nucelotide match, # of times, length of full sequence
printf "MATCHED %s exactly %d times\n", $2, length($1)/3;
print "Length of sequence: $number\n";
exit;
무엇이 당신의 질문입니까? – Borodin
죄송합니다 - 명확하지 않았습니다. 입력 파일에 여러 정규 표현식을 적용하고 싶습니다. – Citizin