Sponsored Content
Top Forums Shell Programming and Scripting Outputting characters after a given string and reporting the characters in the row below --sed Post 303028771 by Xterra on Monday 14th of January 2019 02:55:22 PM
Old 01-14-2019
Don
I modified a bit your script to output the total count and give some format:
Code:
awk -v gene="gene-a gene-b" -v lengths="3 6" -v strings="GCATGAAAACATACA TTTCCAGAAATTGT" '
BEGIN {	nString = split(strings, String)
	split(lengths, OutLen)
	split(gene, Id)
	for(i = 1; i <= nString; i++)
		StringLen[i] = length(String[i])
}
/^@/ {	getline CodonLine
	getline
	getline QualityLine
	for(i = 1; i <= nString; i++)
		if(spot = index(CodonLine, String[i]))
			printf("Gene:\t"Id[i]"\tCodon:\t%s\t\tQuality Score:\t%s\t\n",
			    substr(CodonLine, spot + StringLen[i], OutLen[i]),
			    substr(QualityLine, spot + StringLen[i], OutLen[i]))
}' test.txt | awk '{ count[$0]++ } END {{ print "\n\t\t\t\tSummary\n#############################################################################\nCount\t\tGene\t\tCodon\t\t\tQuality Score\n" } {for (gene in count ) print count[gene] "\t" gene | "sort -k 3"}}'

With the above script I am getting the desired output:
Code:
                                Summary
#############################################################################
Count           Gene            Codon                   Quality Score

1       Gene:   gene-a  Codon:  AAC             Quality Score:  ,ED
2       Gene:   gene-a  Codon:  AAC             Quality Score:  GCC
1       Gene:   gene-a  Codon:  TTT             Quality Score:  +GG
2       Gene:   gene-b  Codon:  TCCAAG          Quality Score:  DGGCGG
1       Gene:   gene-b  Codon:  TCCAAG          Quality Score:  G7DCGG

However, I tried to include the END step in your awk script fail miserably. How can I modify the script so I don't have to "stitch" together the two scripts as shown above?
Thanks!
This User Gave Thanks to Xterra For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

outputting selected characters from within a variable

Hi all, if for example I had a variable containing the string 'hello', is the any way I can output, for example, the e and the 2nd l based on their position in the string not their character (in this case 2 and 4)? any general pointers in the right direction will be much appreciated, at... (3 Replies)
Discussion started by: skinnygav
3 Replies

2. Shell Programming and Scripting

SED help delete characters in a string

Hi Please help me to refine my syntax. I want to delete the excess characters from the out put below. -bash-3.00$ top -b -n2 -d 00.20 |grep Cpu|tail -1 | awk -F ":" '{ print $2 }' | cut -d, -f1 4.4% us now i want to delete the % and us. How wil i do that to make it just 4.4. Thanks (7 Replies)
Discussion started by: redtred
7 Replies

3. Shell Programming and Scripting

Want to remove the last characters from each row of csv using shell script

Hi, I've a csv file seperated by '|' from which I'm trying to remove the excess '|' characters more than the existing fields. My CSV looks like as below. HRLOAD|Service|AddChange|EN PERSONID|STATUS|LASTNAME|FIRSTNAME|ITDCLIENTUSERID|ADDRESSLINE1 10000001|ACTIVE|Testazar1|Testore1|20041|||... (24 Replies)
Discussion started by: rajak.net
24 Replies

4. Shell Programming and Scripting

Delete row if a a particular column has more then three characters in it

Hi i have a data like hw:dsfnsmdf:39843 chr2 76219829 51M atatata 51 872389 hw:dsfnsmdf:39853 chr2 76219839 51M65T atatata 51 872389 hw:dsfnsmdf:39863 chr2 76219849 51M atatata 51 872389 hw:dsfnsmdf:39873 chr2 ... (3 Replies)
Discussion started by: bhargavpbk88
3 Replies

5. Shell Programming and Scripting

sed replacing specific characters and control characters by escaping

sed -e "s// /g" old.txt > new.txt While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Discussion started by: ijustneeda
11 Replies

6. Shell Programming and Scripting

sed cut characters of string

helloo I wonder if there's a way to cut characters out of a string and keep only the last 2 by using sed. For example if there's the todays' date: 2012-05-06 and we only want to keep the last 2 characters which are the day. Is there a quick way to do it with sed? (2 Replies)
Discussion started by: vlm
2 Replies

7. Shell Programming and Scripting

Trouble with sed and substituting a string with special characters in variable

Hey guys, I know that title is a mouthful - I'll try to better explain my struggles a little better... What I'm trying to do is: 1. Query a db and output to a file, a list of column data. 2. Then, for each line in this file, repeat these values but wrap them with: ITEM{ ... (3 Replies)
Discussion started by: ampsys
3 Replies

8. Shell Programming and Scripting

Help with sed command - find a string between two characters

Hi, I have a xml file (Config.xml) <Header name="" TDate="" PDate=""> <Config> {"config" { "Nation" "Pri:|Sec:"}} </Config> </Header> Now I wanted to printed all the strings between "". I tried the following cat Config.xml | sed -n 's/.*\.*//p' ... (8 Replies)
Discussion started by: vivek_damodaran
8 Replies

9. Shell Programming and Scripting

sed replace nth characters with string

Hi, I hope you can help me out please? I need to replace from character 8-16 with AAAAAAAA and the rest should stay the same after character 16 gtwrhtrd11111111rjytwyejtyjejetjyetgeaEHT wrehrhw22222222hytekutkyukrylryilruilrGEQTH hrwjyety33333333gtrhwrjrgkreglqeriugn;RUGNEURGU ... (4 Replies)
Discussion started by: stinkefisch
4 Replies

10. UNIX for Dummies Questions & Answers

Reporting characters after string

I have a file that looks like this: >ID 1 AATAATTCCGGATCGTGC >ID 2 TTTGACAGTAGAC >ID 3 AGACGATGACGAT I am using the following script to report if AATTCCGGATCG is present in any sequence: awk 'FNR==1{n=substr(FILENAME,1,index(FILENAME,".")-1)} { print n "\t"... (10 Replies)
Discussion started by: Xterra
10 Replies
Bio::SeqFeature::Gene::GeneStructure(3pm)		User Contributed Perl Documentation		 Bio::SeqFeature::Gene::GeneStructure(3pm)

NAME
Bio::SeqFeature::Gene::GeneStructure - A feature representing an arbitrarily complex structure of a gene SYNOPSIS
# See documentation of methods. DESCRIPTION
A feature representing a gene structure. As of now, a gene structure really is only a collection of transcripts. See Bio::SeqFeature::Gene::TranscriptI (interface) and Bio::SeqFeature::Gene::Transcript (implementation) for the features of such objects. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Hilmar Lapp Email hlapp-at-gmx.net APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ transcripts Title : transcripts Usage : @transcripts = $gene->transcripts(); Function: Get the transcripts of this gene structure. Many gene structures will have only one transcript. Returns : An array of Bio::SeqFeature::Gene::TranscriptI implementing objects. Args : add_transcript Title : add_transcript() Usage : $gene->add_transcript($transcript); Function: Add a transcript to this gene structure. Returns : Args : A Bio::SeqFeature::Gene::TranscriptI implementing object. flush_transcripts Title : flush_transcripts() Usage : $gene->flush_transcripts(); Function: Remove all transcripts from this gene structure. Returns : Args : add_transcript_as_features Title : add_transcript_as_features Usage : $gene->add_transcript_as_features(@featurelist); Function: take a list of Bio::SeqFeatureI objects and turn them into a Bio::SeqFeature::Gene::Transcript object. Add that transcript to the gene. Returns : nothing Args : a list of Bio::SeqFeatureI compliant objects promoters Title : promoters Usage : @prom_sites = $gene->promoters(); Function: Get the promoter features of this gene structure. This method basically merges the promoters returned by transcripts. Note that OO-modeling of regulatory elements is not stable yet. This means that this method might change or even disappear in a future release. Be aware of this if you use it. Returns : An array of Bio::SeqFeatureI implementing objects. Args : exons Title : exons() Usage : @exons = $gene->exons(); @inital_exons = $gene->exons('Initial'); Function: Get all exon features or all exons of a specified type of this gene structure. Exon type is treated as a case-insensitive regular expression and optional. For consistency, use only the following types: initial, internal, terminal, utr, utr5prime, and utr3prime. A special and virtual type is 'coding', which refers to all types except utr. This method basically merges the exons returned by transcripts. Returns : An array of Bio::SeqFeature::Gene::ExonI implementing objects. Args : An optional string specifying the type of exon. introns Title : introns() Usage : @introns = $gene->introns(); Function: Get all introns of this gene structure. Note that this class currently generates these features on-the-fly, that is, it simply treats all regions between exons as introns. It assumes that the exons in the transcripts do not overlap. This method basically merges the introns returned by transcripts. Returns : An array of Bio::SeqFeatureI implementing objects. Args : poly_A_sites Title : poly_A_sites() Usage : @polyAsites = $gene->poly_A_sites(); Function: Get the poly-adenylation sites of this gene structure. This method basically merges the poly-adenylation sites returned by transcripts. Returns : An array of Bio::SeqFeatureI implementing objects. Args : utrs Title : utrs() Usage : @utr_sites = $gene->utrs('3prime'); @utr_sites = $gene->utrs('5prime'); @utr_sites = $gene->utrs(); Function: Get the features representing untranslated regions (UTR) of this gene structure. You may provide an argument specifying the type of UTR. Currently the following types are recognized: 5prime 3prime for UTR on the 5' and 3' end of the CDS, respectively. This method basically merges the UTRs returned by transcripts. Returns : An array of Bio::SeqFeature::Gene::ExonI implementing objects representing the UTR regions or sites. Args : Optionally, either 3prime, or 5prime for the the type of UTR feature. sub_SeqFeature Title : sub_SeqFeature Usage : @feats = $gene->sub_SeqFeature(); Function: Returns an array of all subfeatures. This method is defined in Bio::SeqFeatureI. We override this here to include the transcripts. Returns : An array Bio::SeqFeatureI implementing objects. Args : none flush_sub_SeqFeature Title : flush_sub_SeqFeature Usage : $gene->flush_sub_SeqFeature(); $gene->flush_sub_SeqFeature(1); Function: Removes all subfeatures. This method is overridden from Bio::SeqFeature::Generic to flush all additional subfeatures, i.e., transcripts, which is almost certainly not what you want. To remove only features added through $gene->add_sub_SeqFeature($feature) pass any argument evaluating to TRUE. Example : Returns : none Args : Optionally, an argument evaluating to TRUE will suppress flushing of all gene structure-specific subfeatures (transcripts). perl v5.14.2 2012-03-02 Bio::SeqFeature::Gene::GeneStructure(3pm)
All times are GMT -4. The time now is 06:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy