samtools sort -@ 30 any.sam > sorted.bam samtools index sorted.bam samtools tview sorted.bam Trinity.fasta -p "ID:35" -d T > result
samtools tview sorted.bam ../../2-Trinity/Trinity.fasta -p "comp0_c0_seq1:35" -d H > 123.html
*.bam file *.fasta file -p posation, fasta nameand star posation ofthe fasta :
Install
wget -c https://github.com/samtools/samtools/releases/download/1.12/samtools-1.12.tar.bz2 tar -xjf samtools-1.12.tar.bz2 cd samtools-1.12 ls ./configure make & make install
awk command: This is a program that scans and processes text based on rules specified in its script or command-line invocation. Here, it’s used to filter lines (reads) from a SAM file.
$6 == length($10)“M”: This condition checks if the CIGAR string (found in column 6 of the SAM format) matches a pattern where it equals the length of the read’s sequence (found in column 10) followed by “M”. The “M” in CIGAR represents a sequence match which may include mismatches as per SAM format specifications, but for the purposes of this script, it suggests an alignment where the read matches the reference over its full length (though technically, mismatches are possible unless further qualified by other tags).
$12 == “NM:i:0”: This condition checks the value of the NM tag, which indicates the number of differences (mismatches, insertions, deletions) between the read and the reference sequence. The NM tag being “0” means there are no mismatches, no insertions, and no deletions—hence a perfect match as far as the alignment scoring is concerned.
Exp.sam: This is the input file to awk, expected to be in SAM format, from which the lines are being read.
| wc -l: This is a pipe to the wc (word count) command with the -l option, which counts the number of lines passed to it. This part of the command will count the number of reads that meet the criteria specified in the awk script, effectively counting how many reads are perfect matches (both in length and alignment accuracy) according to the NM tag.