-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
146 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# Assumes unwrapped fasta, no spaces between records | ||
|
||
# File variables | ||
INFILE=$1 | ||
MISSINGFRAC=$2 | ||
BACKBONEFILE=$3 | ||
|
||
# Remove duplicates using awk processing | ||
awk -v missFrac="$MISSINGFRAC" -v backBoneFile="$BACKBONEFILE" '{ | ||
if(NR % 2 == 1) | ||
{ | ||
header=$0 | ||
} | ||
if(NR == 2) | ||
{ | ||
for(i=1; i<= length($0); i++) | ||
{ | ||
excludeArr[i] = 0; | ||
} | ||
} | ||
if(NR % 2 == 0) | ||
{ | ||
seqArr[header]=$0; | ||
split($0, seq, ""); | ||
for (i=1; i <= length($0); i++) | ||
{ | ||
if(seq[i] == "-" || toupper(seq[i]) == "N") | ||
{ | ||
excludeArr[i]+= 1; | ||
} | ||
} | ||
} | ||
} END{ | ||
firstSeq= 1; | ||
for (header in seqArr) | ||
{ | ||
print header; | ||
split(seqArr[header], seq, ""); | ||
finalSeq = ""; | ||
for (i=1; i <= length(seqArr[header]); i++) | ||
{ | ||
if (excludeArr[i] / (NR / 2) <= missFrac) | ||
{ | ||
finalSeq = finalSeq seq[i]; | ||
if(firstSeq == 1) | ||
{ | ||
if (!beginBackBone) | ||
{ | ||
beginBackBone=i; | ||
endBackBone=i; | ||
} | ||
else if (i - 1 == endBackBone) | ||
{ | ||
endBackBone=i; | ||
} | ||
else if (i - 1 > endBackBone) | ||
{ | ||
print beginBackBone"-"endBackBone >> backBoneFile; | ||
beginBackBone=i; | ||
endBackBone=i; | ||
} | ||
} | ||
} | ||
} | ||
if(firstSeq == 1){print beginBackBone"-"endBackBone >> backBoneFile;} | ||
print finalSeq; | ||
firstSeq = 0; | ||
} | ||
}' $INFILE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# File variables | ||
INFILE=$1 | ||
|
||
# Create bed format using awk processing | ||
awk 'BEGIN{RS = ">"; FS = "\n"} | ||
{ | ||
if(NR > 1) | ||
{ | ||
fasta_seq = "" | ||
for (i=2; i<=NF; i++) | ||
{ | ||
fasta_seq = fasta_seq$i | ||
} | ||
print ">"$1"\n"fasta_seq; | ||
} | ||
}' $INFILE | ||
|
||
|