Hi
I’m new to python and I have a 3.2 python!
I have a file which has some sort of format like this:
Number of segment pairs = 108570; number of pairwise comparisons = 54234
'+' means given segment; '-' means reverse complement
Overlaps Containments No. of Constraints Supporting Overlap
******************* Contig 1 ********************
E_180+
E_97-
******************* Contig 2 ********************
E_254+
E_264+ is in E_254+
E_276+
******************* Contig 3 ********************
E_256-
E_179-
I want to count the number of non-empty lines between the *****contig#****
and I want to get a result like this
contig1=2
contig2=3
contig3=2**
Probably, it’s best to use regular expressions here. You can try the following:
pairsis a list of tuples, where the tuples have the form('Contig x', '...')The second component of each tuple contains the text after the mark
Afterwards, you could count the number of
'\n'in those texts; most easily this can be done via a list comprehension:(edit: if you don’t want to count empty lines you can try:
)