本文整理汇总了C#中ISequence类的典型用法代码示例。如果您正苦于以下问题:C# ISequence类的具体用法?C# ISequence怎么用?C# ISequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISequence类属于命名空间,在下文中一共展示了ISequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindMatch
/// <summary>
/// Find the matches for given searchStrings in sequence and returns
/// the matched strings with indices found at.
/// </summary>
/// <param name="sequence">Input sequence.</param>
/// <param name="searchPatterns">Strings to be searched.</param>
/// <returns>Matches found in sequence.</returns>
public IDictionary<string, IList<int>> FindMatch(ISequence sequence, IList<string> searchPatterns)
{
if (sequence == null)
{
throw new ArgumentNullException("sequence");
}
if (searchPatterns == null)
{
throw new ArgumentNullException("searchPatterns");
}
// Create tasks
IList<Task<KeyValuePair<string, IList<int>>>> tasks = searchPatterns.Select(
searchString => Task<KeyValuePair<string, IList<int>>>.Factory.StartNew(
t => new KeyValuePair<string, IList<int>>(searchString, FindMatch(sequence, searchString)),
TaskCreationOptions.None)).ToList();
// Wait for all the task
Task.WaitAll(tasks.ToArray());
IDictionary<string, IList<int>> results = new Dictionary<string, IList<int>>();
foreach (Task<KeyValuePair<string, IList<int>>> task in tasks)
{
results.Add(task.Result.Key, task.Result.Value);
}
return results;
}
示例2: WaitFor
/// <summary>
/// <see cref="IWaitStrategy.WaitFor"/>
/// </summary>
public long WaitFor(long sequence, Sequence cursor, ISequence dependentSequence, ISequenceBarrier barrier)
{
long startTime = 0;
int counter = _spinTries;
do
{
long availableSequence;
if ((availableSequence = dependentSequence.Value) >= sequence)
return availableSequence;
if (0 == --counter)
{
if (0 == startTime)
{
startTime = GetSystemTimeTicks();
}
else
{
var timeDelta = GetSystemTimeTicks() - startTime;
if (timeDelta > _yieldTimeoutTicks)
{
return _fallbackStrategy.WaitFor(sequence, cursor, dependentSequence, barrier);
}
if (timeDelta > _spinTimeoutTicks)
{
Thread.Yield();
}
}
counter = _spinTries;
}
}
while (true);
}
示例3: WaitFor
/// <summary>
/// <see cref="IWaitStrategy.WaitFor"/>
/// </summary>
public long WaitFor(long sequence, Sequence cursor, ISequence dependentSequence, ISequenceBarrier barrier)
{
var timeSpan = _timeout;
if (cursor.Value < sequence)
{
lock (_gate)
{
while (cursor.Value < sequence)
{
barrier.CheckAlert();
if (!Monitor.Wait(_gate, timeSpan))
{
throw TimeoutException.Instance;
}
}
}
}
long availableSequence;
while ((availableSequence = dependentSequence.Value) < sequence)
{
barrier.CheckAlert();
}
return availableSequence;
}
示例4: RemoveSequence
public static bool RemoveSequence(ref ISequence[] sequences, ISequence sequence)
{
int numToRemove;
ISequence[] oldSequences;
ISequence[] newSequences;
do
{
oldSequences = Volatile.Read(ref sequences);
numToRemove = CountMatching(oldSequences, sequence);
if (numToRemove == 0)
break;
var oldSize = oldSequences.Length;
newSequences = new ISequence[oldSize - numToRemove];
for (int i = 0, pos = 0; i < oldSize; i++)
{
var testSequence = oldSequences[i];
if (sequence != testSequence)
{
newSequences[pos++] = testSequence;
}
}
}
while (Interlocked.CompareExchange(ref sequences, newSequences, oldSequences) != oldSequences);
return numToRemove != 0;
}
示例5: SequenceIDHeaderToRange
/// <summary>
/// Convert fasta sequence id to a string array
/// </summary>
public static string[,] SequenceIDHeaderToRange(ISequence sequence)
{
var formattedData = new string[1,2];
formattedData[0, 0] = Properties.Resources.Sequence_ID;
formattedData[0, 1] = (sequence != null) ? sequence.ID : "";
return formattedData;
}
示例6: DeltaAlignment
///<summary>
/// Initializes a new instance of the DeltaAlignment class
/// </summary>
/// <param name="referenceSequence">Reference Sequence</param>
/// <param name="querySequence">Query Sequence</param>
public DeltaAlignment(ISequence referenceSequence, ISequence querySequence)
{
this.internalDeltas = new List<long>();
ReferenceSequence = referenceSequence;
QuerySequence = querySequence;
QueryDirection = Cluster.ForwardDirection;
}
示例7: AddSequences
public static void AddSequences(ref ISequence[] sequences, ICursored cursor, params ISequence[] sequencesToAdd)
{
long cursorSequence;
ISequence[] updatedSequences;
ISequence[] currentSequences;
do
{
currentSequences = Volatile.Read(ref sequences);
updatedSequences = new ISequence[currentSequences.Length + sequencesToAdd.Length];
Array.Copy(currentSequences, updatedSequences, currentSequences.Length);
cursorSequence = cursor.Cursor;
var index = currentSequences.Length;
foreach (var sequence in sequencesToAdd)
{
sequence.SetValue(cursorSequence);
updatedSequences[index++] = sequence;
}
}
while (Interlocked.CompareExchange(ref sequences, updatedSequences, currentSequences) != currentSequences);
cursorSequence = cursor.Cursor;
foreach (var sequence in sequencesToAdd)
{
sequence.SetValue(cursorSequence);
}
}
示例8: Transcribe
/// <summary>
/// Transcribes a DNA sequence into an RNA sequence. The length
/// of the resulting sequence will equal the length of the source
/// sequence. Gap and ambiguous characters will also be transcribed.
/// For example:
/// Sequence dna = new Sequence(Alphabets.DNA, "TACCGC");
/// Sequence rna = Transcription.Transcribe(dna);
/// rna.ToString() would produce "AUGGCG"
/// </summary>
/// <param name="dnaSource">The dna source sequence to be transcribed.</param>
/// <returns>The transcribed RNA sequence.</returns>
public static ISequence Transcribe(ISequence dnaSource)
{
if (dnaSource == null)
{
throw new ArgumentNullException("dnaSource");
}
if (dnaSource.Alphabet != Alphabets.DNA && dnaSource.Alphabet != Alphabets.AmbiguousDNA)
{
throw new InvalidOperationException(Properties.Resource.InvalidAlphabetType);
}
byte[] transcribedResult = new byte[dnaSource.Count];
long counter = 0;
foreach (byte n in dnaSource)
{
transcribedResult[counter] = GetRnaComplement(n);
counter++;
}
var alphabet = dnaSource.Alphabet == Alphabets.DNA ? Alphabets.RNA : Alphabets.AmbiguousRNA;
Sequence result = new Sequence(alphabet, transcribedResult);
result.ID = "Complement: " + dnaSource.ID;
return result;
}
示例9: _UseSequenceData
private void _UseSequenceData(ISequence sequence)
{
if (!_persistPreFilterCache) {
_intentPreFilter.ClearCache();
}
_intentPreFilter.Data = sequence.SequenceData.EffectData;
}
示例10: ExportDialog
public ExportDialog(ISequence sequence)
{
InitializeComponent();
ForeColor = ThemeColorTable.ForeColor;
BackColor = ThemeColorTable.BackgroundColor;
ThemeUpdateControls.UpdateControls(this);
Icon = Resources.Icon_Vixen3;
_sequence = sequence;
_exportOps = new Export();
_exportOps.SequenceNotify += SequenceNotify;
_sequenceFileName = _sequence.FilePath;
IEnumerable<string> mediaFileNames =
(from media in _sequence.SequenceData.Media
where media.GetType().ToString().Contains("Audio")
where media.MediaFilePath.Length != 0
select media.MediaFilePath);
_audioFileName = "";
if (mediaFileNames.Count() > 0)
{
_audioFileName = mediaFileNames.First();
}
exportProgressBar.Visible = false;
currentTimeLabel.Visible = false;
_cancelled = false;
backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
}
示例11: WaitFor
/// <summary>
/// <see cref="IWaitStrategy.WaitFor"/>.
/// </summary>
public long WaitFor(long sequence, Sequence cursor, ISequence dependentSequence, ISequenceBarrier barrier)
{
var milliseconds = _timeoutInMilliseconds;
long availableSequence;
if (cursor.Value < sequence)
{
lock (_lock)
{
while (cursor.Value < sequence)
{
Interlocked.Exchange(ref _signalNeeded, 1);
barrier.CheckAlert();
if (!Monitor.Wait(_lock, milliseconds))
{
throw TimeoutException.Instance;
}
}
}
}
while ((availableSequence = dependentSequence.Value) < sequence)
{
barrier.CheckAlert();
}
return availableSequence;
}
示例12: GetTypeMapping
public virtual RelationalTypeMapping GetTypeMapping(ISequence sequence)
=> GetTypeMapping(
/*specifiedType:*/ null,
sequence.Name,
sequence.Type,
isKey: false,
isConcurrencyToken: false);
示例13: BuildKmerDictionary
/// <summary>
/// For input sequence, constructs k-mers by sliding
/// a frame of size kmerLength along the input sequence.
/// Track positions of occurance for each kmer in sequence.
/// Constructs KmersOfSequence for sequence and associated k-mers.
/// </summary>
/// <param name="sequence">Input sequence.</param>
/// <param name="kmerLength">K-mer length.</param>
/// <returns>KmersOfSequence constructed from sequence and associated k-mers.</returns>
public static KmerPositionDictionary BuildKmerDictionary(ISequence sequence, int kmerLength)
{
if (sequence == null)
{
throw new ArgumentNullException("sequence");
}
if (kmerLength > sequence.Count)
{
throw new ArgumentException(Properties.Resource.KmerLengthIsTooLong);
}
// kmers maintains the map between k-mer strings to list of positions in sequence.
KmerPositionDictionary kmers = new KmerPositionDictionary();
// Sequence 'kmer' stores the k-mer in each window.
// Construct each k-mer using range from sequence.
for (long i = 0; i <= sequence.Count - kmerLength; ++i)
{
ISequence kmerString = sequence.GetSubSequence(i, kmerLength);
if (kmers.ContainsKey(kmerString))
{
kmers[kmerString].Add(i);
}
else
{
kmers[kmerString] = new List<long>() { i };
}
}
return kmers;
}
示例14: SequenceStartedEventArgs
public SequenceStartedEventArgs(ISequence sequence, ITiming timingSource, TimeSpan startTime, TimeSpan endTime)
{
Sequence = sequence;
TimingSource = timingSource;
StartTime = startTime;
EndTime = endTime;
}
示例15: Construct
/// <summary>
/// Pre-optimized Construct constructor.
/// </summary>
/// <param name="fragList">Fragment list.</param>
public Construct(List<Overlap> overlaps, ISequence sequence, DesignerSettings settings)
: base()
{
this.Overlaps = overlaps;
this.Sequence = sequence;
this.Settings = settings;
}