#!/usr/bin/perl $inputFile = $ARGV[0]; chomp($inputFile); open(IN,"$inputFile"); unless(open(IN, $inputFile)){ print "Error: Cannot open file \"$inputFile\".\n\n"; exit; } @genes=; delete($Dna[0]); close IN; $i=1; foreach $geneLine(@genes){ #$geneLine = "ENSG00000204873 TAAATAGTGGTCATAACAAATATATTATCTAATAAG"; @gl = split('\t', $geneLine); #print "\n".$gl[0]." - ".$gl[1]; #for($i=1; $i<2; $i++){ $chrFile = "human_chromosomes/chr".$i.".fa"; chomp($chrFile); open(CHR,"$chrFile"); unless(open(CHR, $chrFile)){ print "Error: Cannot open file \"$snpFile\".\n\n"; exit; } @chr = ; delete($chr[0]); close CHR; $chrSeq = join('', @chr); $chrSeq =~s/\s//g; # Remove white space $chrSeq =~ s/($chrSeq)/\U$1/gi; @chrFrags = split/$gl[1]/,$chrSeq; $count = @chrFrags; if($count>1){ $n = length($chrFrags[0]); $startPos = $n; $length = length($gl[1]); $snpFile = "SNP_CHROMOSOMES/chr".$i.".subst.fa"; chomp($snpFile); open(SNP,"$snpFile"); unless(open(SNP, $snpFile)){ print "Error: Cannot open file \"$snpFile\".\n\n"; exit; } @snp = ; delete($snp[0]); close SNP; $snpSeq = join('', @snp); $snpSeq =~s/\s//g; # Remove white space $snpSeq =~ s/($snpSeq)/\U$1/gi; $seqMatch = substr($snpSeq,$startPos,$length); print "Gene ID: $gl[0]\nStart position = $startPos \nLength = $length\n"; print "Choromosome $i.\n"; print "\nGene : ".$gl[1]."\nSNP : $seqMatch\n"; ($snpMatch1=$seqMatch)=~s/[ATGC]/-/g; ($snpMatch2=$snpMatch1)=~s/[\w]/+/g; #$snpMatch2=~s/[-]/0/g; print "Match: $snpMatch2\n\n#######################################################################################################\n\n"; } else{ #print "match not found\n"; } #} }