sequences

Detecting sequence of at least 3 sequential numbers from a given list

随声附和 提交于 2019-12-17 17:53:09
问题 I have a list of numbers e.g. 21,4,7,9,12,22,17,8,2,20,23 I want to be able to pick out sequences of sequential numbers (minimum 3 items in length), so from the example above it would be 7,8,9 and 20,21,22,23. I have played around with a few ugly sprawling functions but I am wondering if there is a neat LINQ-ish way to do it. Any suggestions? UPDATE: Many thanks for all the responses, much appriciated. Im am currently having a play with them all to see which would best integrate into our

Logic to generate an alphabetical sequence in C# [closed]

半世苍凉 提交于 2019-12-14 03:38:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . The sequence should go like this. A-Z,AA-AZ,BA-BZ,CA-CZ,.......,ZA-ZZ After ZZ it should start from AAA . Then AAA to ZZZ and then AAAA to ZZZZ and so on. This sequence is pretty much like that of an Excel sheet. Edit: Added my code private void SequenceGenerator() { var numAlpha

make sure array is sequential in C#

喜夏-厌秋 提交于 2019-12-13 18:23:09
问题 I've got an array of integers we're getting from a third party provider. These are meant to be sequential but for some reason they miss a number (something throws an exception, its eaten and the loop continues missing that index). This causes our system some grief and I'm trying to ensure that the array we're getting is indeed sequential. The numbers start from varying offsets (sometimes 1000, sometimes 5820, others 0) but whatever the start, its meant to go from there. What's the fastest

Matching token sequences

自闭症网瘾萝莉.ら 提交于 2019-12-13 16:02:21
问题 I have a set of n tokens (e.g., a, b, c) distributed among a bunch of other tokens. I would like to know if all members of my set occur within a given number of positions (window size). It occurred to me that it may be possible to write a RegEx to capture this state, but the exact syntax eludes me. 11111 012345678901234 ab ab bc a cba In this example, given window size=5, I would like to match cba at positions 12-14, and abc in positions 3-7. Is there a way to do this with RegEx, or is there

Select sequences in a fasta file with more than 300 aa and “C” occurs at least 4 times

故事扮演 提交于 2019-12-13 14:28:10
问题 I have a fasta file which contains protein sequences. I'd like to select sequences with more than 300 amino acids and Cysteine (C) amino acid appears more than 4 times. I've used this command to select sequences with more than 300 aa: cat 72hDOWN-fasta.fasta | bioawk -c fastx 'length($seq) > 300{ print ">"$name; print $seq }' Some sequence example: >jgi|Triasp1|216614|CE216613_3477 MPSLYLTSALGLLSLLPAAQAGWNPNSKDNIVVYWGQDAGSIGQNRLSYYCENAPDVDVI

Numeric sequence with condition [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-13 08:36:24
问题 This question already has answers here : Create counter with multiple variables [duplicate] (6 answers) Closed 4 years ago . I have a big data.frame that I want to generate a new column (called Seq) to, which has a sequential values that restarts every time there is a change in a different column. Here is an example of the data.frame (with omitted columns) and the new column called Seq. As you can see there is a sequentiel count, but everytime there is a new IDPath, the sequentiel count

Convert List of Numbers to String Ranges

♀尐吖头ヾ 提交于 2019-12-12 08:46:07
问题 I'd like to know if there is a simple (or already created) way of doing the opposite of this: Generate List of Numbers from Hyphenated.... This link could be used to do: >> list(hyphen_range('1-9,12,15-20,23')) [1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 23]: I'm looking to do the opposite (note that 10 and 21 are included so it would be compatible with the range function, where range(1,10)=[1,2,3,4,5,6,7,8,9]): >> list_to_ranges([1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19,

Where can I find the time and space complexity of the built-in sequence types in Python

a 夏天 提交于 2019-12-12 07:42:05
问题 I've been unable to find a source for this information, short of looking through the Python source code myself to determine how the objects work. Does anyone know where I could find this online? 回答1: Checkout the TimeComplexity page on the py dot org wiki. It covers set/dicts/lists/etc at least as far as time complexity goes. 回答2: Raymond D. Hettinger does an excellent talk (slides) about Python's built-in collections called 'Core Python Containers - Under the Hood'. The version I saw

F# take subsequence of a sequence

半腔热情 提交于 2019-12-12 04:53:00
问题 I need to define a function, which takes a sequence and integers i and n as parameters and returns sub list or sub sequence of this seq, defined as followed: . 回答1: You can write: let subSeq i n = Seq.skip i >> Seq.take n Which is used, e.g.: let result = subSeq 5 10 [0..20] 来源: https://stackoverflow.com/questions/34093543/f-take-subsequence-of-a-sequence

pg_dump setting of sequences

余生长醉 提交于 2019-12-12 02:46:39
问题 I've recently started developing apps with PostgreSQL as backend DB (imposed on me) with no previous experience of Postgres. So far it hasn't been too bad, but now I run into a problem to which I cannot find answer for. I created a batch scripts that runs a pg_dump command for a particular database on the server. This batch file is executed on schedule by the pgAgent. The pg_dump itself seems to work ok. All the database structure and data are dumped to a file. However the sequences are all