<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Owner]]></title>
	<link>https://bioinformaticsonline.com/snippets/owner/abhinav?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/owner/abhinav?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44725/bash-script-to-discover-pirna-in-transcriptome-data</guid>
	<pubDate>Fri, 13 Dec 2024 11:47:00 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44725/bash-script-to-discover-pirna-in-transcriptome-data</link>
	<title><![CDATA[Bash script to discover piRNA in transcriptome data !]]></title>
	<description><![CDATA[<code>#!/bin/bash

# Variables (modify these as per your setup)
INPUT_FASTQ=&quot;input_reads.fastq&quot;
ADAPTER_SEQ=&quot;TGGAATTCTCGGGTGCCAAGG&quot;
REFERENCE_GENOME=&quot;reference_genome.fa&quot;
BOWTIE_INDEX=&quot;reference_index&quot;
OUTPUT_DIR=&quot;piRNA_analysis&quot;
THREADS=4

# Create output directory
mkdir -p $OUTPUT_DIR

# Step 1: Quality Control
echo &quot;Running FastQC for quality control...&quot;
fastqc $INPUT_FASTQ -o $OUTPUT_DIR

# Step 2: Adapter Trimming
echo &quot;Trimming adapters with Cutadapt...&quot;
cutadapt -a $ADAPTER_SEQ -o $OUTPUT_DIR/trimmed_reads.fastq $INPUT_FASTQ

# Step 3: Mapping Reads to Reference Genome
echo &quot;Mapping reads to reference genome using Bowtie...&quot;
bowtie -v 1 -k 1 --best -p $THREADS $BOWTIE_INDEX $OUTPUT_DIR/trimmed_reads.fastq -S $OUTPUT_DIR/aligned_reads.sam

# Step 4: Convert SAM to BAM and Sort
echo &quot;Converting SAM to BAM and sorting...&quot;
samtools view -Sb $OUTPUT_DIR/aligned_reads.sam | samtools sort -o $OUTPUT_DIR/sorted_reads.bam

# Step 5: Extract Reads of piRNA Size (24-32 nt)
echo &quot;Filtering reads of size 24-32 nt...&quot;
bedtools bamtofastq -i $OUTPUT_DIR/sorted_reads.bam -fq $OUTPUT_DIR/all_reads.fastq
seqkit seq -m 24 -M 32 $OUTPUT_DIR/all_reads.fastq &gt; $OUTPUT_DIR/piRNA_size_reads.fastq

# Step 6: Detect Sequence Bias (Optional)
echo &quot;Checking sequence bias using WebLogo-compatible data...&quot;
seqkit fx2tab $OUTPUT_DIR/piRNA_size_reads.fastq | cut -f2 | awk &#039;{print &quot;&gt;seq&quot;NR&quot;\n&quot;$0}&#039; &gt; $OUTPUT_DIR/piRNA_sequences.fa

# Step 7: Identify piRNA Clusters
# This step requires a tool like proTRAC or PIRANHA. Example placeholder:
echo &quot;Identifying piRNA clusters (requires proTRAC or PIRANHA)...&quot;
# Example with proTRAC:
# proTRAC.pl -s $OUTPUT_DIR/sorted_reads.bam -g $REFERENCE_GENOME -o $OUTPUT_DIR/clusters

# Step 8: Annotate Clusters
# Annotation depends on your genome&#039;s annotation file
# bedtools intersect example placeholder:
# bedtools intersect -a clusters.bed -b genome_annotation.gtf &gt; annotated_clusters.bed

# Step 9: Clean up intermediate files (optional)
echo &quot;Cleaning up intermediate files...&quot;
rm $OUTPUT_DIR/aligned_reads.sam $OUTPUT_DIR/all_reads.fastq

# Done
echo &quot;piRNA discovery pipeline completed! Results are in $OUTPUT_DIR.&quot;</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44567/python-script-to-parse-a-fastq-file</guid>
	<pubDate>Mon, 10 Jun 2024 11:20:27 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44567/python-script-to-parse-a-fastq-file</link>
	<title><![CDATA[Python script to parse a FASTQ file !]]></title>
	<description><![CDATA[<code>#Python script to parse a FASTQ file and extract basic information such as the sequence identifier, sequence, and quality scores
#pip install biopython

from Bio import SeqIO

def parse_fastq(fastq_file):
    # Initialize a list to store parsed sequences
    sequences = []

    # Read the sequences from the FASTQ file
    for record in SeqIO.parse(fastq_file, &quot;fastq&quot;):
        sequence_info = {
            &quot;id&quot;: record.id,
            &quot;sequence&quot;: str(record.seq),
            &quot;quality&quot;: record.letter_annotations[&quot;phred_quality&quot;]
        }
        sequences.append(sequence_info)

    return sequences

# Example usage
fastq_file = &quot;path/to/your/sequences.fastq&quot;
parsed_sequences = parse_fastq(fastq_file)

# Print out the parsed sequences
for seq in parsed_sequences:
    print(f&quot;ID: {seq[&#039;id&#039;]}&quot;)
    print(f&quot;Sequence: {seq[&#039;sequence&#039;]}&quot;)
    print(f&quot;Quality: {seq[&#039;quality&#039;]}&quot;)
    print()</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44566/python-script-to-calculate-basic-genome-stats</guid>
	<pubDate>Mon, 10 Jun 2024 11:18:32 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44566/python-script-to-calculate-basic-genome-stats</link>
	<title><![CDATA[Python script to calculate basic genome stats !]]></title>
	<description><![CDATA[<code>from Bio import SeqIO

def calculate_genome_stats(fasta_file):
    # Initialize variables to store genome statistics
    genome_length = 0
    gc_count = 0
    a_count = 0
    t_count = 0
    c_count = 0
    g_count = 0

    # Read the genome sequence from the FASTA file
    for record in SeqIO.parse(fasta_file, &quot;fasta&quot;):
        sequence = record.seq
        genome_length += len(sequence)
        a_count += sequence.count(&#039;A&#039;)
        t_count += sequence.count(&#039;T&#039;)
        c_count += sequence.count(&#039;C&#039;)
        g_count += sequence.count(&#039;G&#039;)
        gc_count += sequence.count(&#039;G&#039;) + sequence.count(&#039;C&#039;)

    # Calculate GC content
    gc_content = (gc_count / genome_length) * 100 if genome_length &gt; 0 else 0

    # Print genome statistics
    print(f&quot;Genome Length: {genome_length} bp&quot;)
    print(f&quot;A Count: {a_count}&quot;)
    print(f&quot;T Count: {t_count}&quot;)
    print(f&quot;C Count: {c_count}&quot;)
    print(f&quot;G Count: {g_count}&quot;)
    print(f&quot;GC Content: {gc_content:.2f}%&quot;)

# Example usage
fasta_file = &quot;path/to/your/genome.fasta&quot;
calculate_genome_stats(fasta_file)</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44565/python-script-to-create-fastq-file-with-random-sequences</guid>
	<pubDate>Mon, 10 Jun 2024 08:21:32 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44565/python-script-to-create-fastq-file-with-random-sequences</link>
	<title><![CDATA[Python script to create fastq file with random sequences]]></title>
	<description><![CDATA[<code>import random

def generate_random_sequence(length):
    bases = [&#039;A&#039;, &#039;C&#039;, &#039;G&#039;, &#039;T&#039;]
    return &#039;&#039;.join(random.choice(bases) for _ in range(length))

def generate_random_quality(length):
    return &#039;&#039;.join(chr(random.randint(33, 73)) for _ in range(length))

def generate_fastq_entry(sequence_length):
    sequence = generate_random_sequence(sequence_length)
    quality = generate_random_quality(sequence_length)
    return f&quot;@SEQ_ID\n{sequence}\n+\n{quality}\n&quot;

def generate_fastq_file(num_entries, sequence_length, file_path):
    with open(file_path, &#039;w&#039;) as f:
        for _ in range(num_entries):
            entry = generate_fastq_entry(sequence_length)
            f.write(entry)

# Generate a FASTQ file with 5 entries, each with a sequence length of 50 bases
generate_fastq_file(100, 50, &#039;random.fastq&#039;)</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44340/r-script-for-circos-plot</guid>
	<pubDate>Tue, 11 Jul 2023 01:41:03 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44340/r-script-for-circos-plot</link>
	<title><![CDATA[R script for Circos plot !]]></title>
	<description><![CDATA[<code>#!/usr/bin/env Rscript
library(RCircos)

# usage: Rscript make_circos.r &lt;sv table&gt; &lt;sample name&gt; &lt;gene label table&gt; &lt;cnv data&gt; &lt;out&gt;

# parse args
args = commandArgs(trailingOnly=TRUE)
sv.file &lt;- args[1]
sample.name &lt;- args[2]
gene.label.file &lt;- args[3]
cnv.file &lt;- args[4]
out.file &lt;- args[5]
# TMP &lt;- Sys.getenv(&quot;TMP_DIR&quot;) 
# tmp.bed = paste0(TMP ,&quot;/&quot; , sample.name, &quot;_bkpts.bed&quot;)
tmp.bed = paste0(sample.name, &quot;_bkpts.bed&quot;)

# load prereq data
data(UCSC.HG19.Human.CytoBandIdeogram)

# set core parameters
chr.exclude &lt;- NULL;
cyto.info &lt;- UCSC.HG19.Human.CytoBandIdeogram;
tracks.inside &lt;- 10;
tracks.outside &lt;- 5;
RCircos.Set.Core.Components(cyto.info, chr.exclude, tracks.inside, tracks.outside);
rcircos.params &lt;- RCircos.Get.Plot.Parameters();
rcircos.params$text.size &lt;- 1
RCircos.Reset.Plot.Parameters(rcircos.params)
rcircos.cyto &lt;- RCircos.Get.Plot.Ideogram();
rcircos.position &lt;- RCircos.Get.Plot.Positions();
RCircos.List.Plot.Parameters()

link.data &lt;- tryCatch(read.table(sv.file, sep = &#039;,&#039;, stringsAsFactors = F, header = T), error=function(e) data.frame())
                    
if (nrow(link.data) != 0) {
  
  link.data &lt;- transform(link.data,
                         chromStart = as.numeric(chromStart),
                         chromEnd = as.numeric(chromEnd),
                         chromStart.1 = as.numeric(chromStart.1),
                         chromEnd.1 = as.numeric(chromEnd.1))
  
  # write a bed file of all breakpoints to intersect with gene label table
  bkpts.1 &lt;- link.data[c(&quot;Chromosome&quot;, &quot;chromStart&quot;, &quot;chromEnd&quot;)]
  bkpts.2 &lt;- link.data[c(&quot;Chromosome.1&quot;, &quot;chromStart.1&quot;, &quot;chromEnd.1&quot;)]
  colnames(bkpts.2) &lt;- colnames(bkpts.1)
  write.table(rbind(bkpts.1, bkpts.2), tmp.bed, sep = &#039;\t&#039;, quote = F, col.names = F, row.names = F)
  
  # only keep labels that fall within an event
  print(paste0(&quot;bedtools intersect -wb -a &quot;, tmp.bed, &quot; -b &quot;, gene.label.file))
  gene.labels &lt;- system(paste0(&quot;bedtools intersect -wb -a &quot;, tmp.bed, &quot; -b &quot;, gene.label.file), intern = T)
  gene.labels &lt;- data.frame(do.call(&#039;rbind&#039;, strsplit(gene.labels, &#039;\t&#039;, fixed=TRUE)), stringsAsFactors = F)
  if (nrow(gene.labels) &gt; 0) {
    gene.labels &lt;- gene.labels[,4:ncol(gene.labels)]
    
    # deduplicate labels
    gene.labels &lt;- gene.labels[!duplicated(gene.labels),]
    colnames(gene.labels) &lt;- c(&quot;Chromosome&quot;, &quot;chromStart&quot;, &quot;chromEnd&quot;, &quot;gene&quot;)
    gene.labels &lt;- transform(gene.labels,
                             chromStart = as.numeric(chromStart),
                             chromEnd = as.numeric(chromEnd))
  }
  
  # make the plot
  png(file=out.file, height=3000, width=3000, res = 500)
  RCircos.Set.Plot.Area()
  RCircos.Chromosome.Ideogram.Plot()
  track.num &lt;- 2
  RCircos.Link.Plot(link.data, track.num, TRUE)
  title(sample.name, line=-1)
  
  # label the genes
  if (nrow(gene.labels) &gt; 0) {
    name.col &lt;- 4
    side &lt;- &quot;out&quot;
    track.num &lt;- 1
    RCircos.Gene.Connector.Plot(gene.labels, track.num, side);
    track.num &lt;- 2
    RCircos.Gene.Name.Plot(gene.labels, name.col, track.num, side);
  }
    
  # remove intermediate file
  system(paste0(&quot;rm -f &quot;, tmp.bed))
  
} else {
  # make empty plot
  png(file=out.file, height=3000, width=3000, res = 500)
  RCircos.Set.Plot.Area()
  RCircos.Chromosome.Ideogram.Plot()
  title(sample.name, line=-1)
}
                    
# parse cnv data
cnv = tryCatch(read.csv(cnv.file, stringsAsFactors = F), error=function(e) data.frame())
               
if (nrow(cnv) != 0) {
    colnames(cnv) &lt;- c(&quot;Chromosome&quot;, &quot;chromStart&quot;, &quot;chromEnd&quot;, &quot;cnv&quot;)
    cnv$Chromosome &lt;- paste0(&#039;chr&#039;, cnv$Chromosome)
    cnv$GeneName &lt;- &quot;gene&quot;
    cnv &lt;- cnv[, c(&quot;Chromosome&quot;, &quot;chromStart&quot;, &quot;chromEnd&quot;, &quot;GeneName&quot;, &quot;cnv&quot;)]
}
                    
# add CNV heatmap track
if (nrow(cnv) != 0) {
  RCircos.Heatmap.Plot(cnv, data.col = 5, track.num = 1, side = &quot;in&quot;)
}
                   
dev.off()

#-------- DATA FORMAT ------
chr1	11869	14412	DDX11L1
chr1	14363	29806	WASH7P
chr1	29554	31109	MIR1302-10
chr1	34554	36081	FAM138A
chr1	52473	54936	OR4G4P
chr1	62948	63887	OR4G11P
chr1	69091	70008	OR4F5
chr1	131025	134836	CICP27
chr1	134901	139379	AL627309.1
chr1	157784	157887	RNU6-1100P
chr1	227615	267253	AP006222.2
chr1	228292	228775	AP006222.1
chr1	317720	453948	RP4-669L17.10
chr1	326096	328112	RP4-669L17.8
chr1	329431	332236	CICP7
chr1	334126	334305	RP4-669L17.4
chr1	367640	368634	OR4F29
chr1	379105	379467	WBP1LP7</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/43992/perl-script-to-read-the-next-line-of-a-file</guid>
	<pubDate>Mon, 17 Oct 2022 23:19:56 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/43992/perl-script-to-read-the-next-line-of-a-file</link>
	<title><![CDATA[Perl script to read the next line of a file !]]></title>
	<description><![CDATA[<code>my $line = &lt;$fileHandler&gt;;
while(1) { # keep looping until I say so
    my $nextLine = &lt;$fileHandler&gt;;

    if ($line =~ m/&gt;/ || !defined $nextLine) {
        ### Do the stuff
    }
    ### Do any other stuff;

    last unless defined $nextLine;
    $line = $nextLine;
}</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/43965/extract-the-mapped-and-unmapped-reads</guid>
	<pubDate>Fri, 23 Sep 2022 06:18:33 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/43965/extract-the-mapped-and-unmapped-reads</link>
	<title><![CDATA[Extract the mapped and unmapped reads !]]></title>
	<description><![CDATA[<code>PROCESSORS=20

#Single_End_Layout:
samtools view --threads $PROCESSORS -b -F 4 in.bam &gt; mapped.bam
samtools view --threads $PROCESSORS -b -f 4 in.bam &gt; unmapped.bam

#Paired_End_Layout
samtools view --threads $PROCESSORS -b -f 2 in.bam &gt; mapped.bam
samtools view --threads $PROCESSORS -b -F 2 in.bam &gt; unmapped.bam</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/43948/genome-scaffolding-and-gap-filling</guid>
	<pubDate>Wed, 24 Aug 2022 05:41:32 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/43948/genome-scaffolding-and-gap-filling</link>
	<title><![CDATA[Genome Scaffolding and gap filling !]]></title>
	<description><![CDATA[<code>scaffolding with ARCS v1.0.3 (−c3, −l,4, −a,0.9, −z500, −m50, −20 000, −e30000, −s90).  https://github.com/bcgsc/arcs

Next, automated gap filling was performed using Sealer v2.0.1 (−L150, -P10, −k75-115 [step = 10]) https://github.com/bcgsc/abyss/tree/sealer-release</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/43761/install-varscan-on-ubuntu-linux</guid>
	<pubDate>Wed, 02 Feb 2022 02:38:25 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/43761/install-varscan-on-ubuntu-linux</link>
	<title><![CDATA[Install Varscan on Ubuntu / Linux !]]></title>
	<description><![CDATA[<code>#Varscan is a java program designed to call variants in sequencing data. It was developed at the Genome Institute at Washington University and is hosted on github. To use Varscan we simply need to download the distributed jar file into our ~/workspace/bin. As with the other java programs which have already been installed in this section we can invoke Varscan via java -jar.

# Install Varscan
cd ~/workspace/bin
curl -L -k -o VarScan.v2.4.2.jar https://github.com/dkoboldt/varscan/releases/download/2.4.2/VarScan.v2.4.2.jar
java -jar ~/workspace/bin/VarScan.v2.4.2.jar</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>
<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/43760/install-stringtie-on-ubuntu-linux</guid>
	<pubDate>Wed, 02 Feb 2022 02:36:02 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/43760/install-stringtie-on-ubuntu-linux</link>
	<title><![CDATA[Install StringTie on ubuntu / Linux !]]></title>
	<description><![CDATA[<code>#StringTie is a software program to perform transcript assembly and quantification of RNAseq data. The binary distributions are available so to install we can just download this distribution and extract it. Like with our other programs we also make a symlink to make it easier to find.

# download and extract
cd ~/workspace/bin
wget http://ccb.jhu.edu/software/stringtie/dl/stringtie-1.3.0.Linux_x86_64.tar.gz
tar -xzvf stringtie-1.3.0.Linux_x86_64.tar.gz

# make symlink
ln -s ~/workspace/bin/stringtie-1.3.0.Linux_x86_64/stringtie ~/workspace/bin/stringtie

# test installation
~/workspace/bin/stringtie -h</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>

</channel>
</rss>